2  '
4  'SEE INTERFACE AGE -- JUNE 1981 -- PAGE 98
6  '
10 PRINT:PRINT"CROSSREF   -   BASIC-80 VERSION OF 05/19/80"
20 PRINT:PRINT"COPYRIGHT (C) 1980 BY ADVANCED INFORMATICS"
30 PRINT:PRINT"LISTS ALL VARIABLES & REFERENCED LINE #'S"
40 PRINT"-------------------------------------------"
50 '
60 DEFINT I-J:LW=80
70 ON ERROR GOTO 1501
80 DIM RW$(126),PT%(25),F$(10)
90 I=4000:DIM VNXT%(I+90),VV$(I+90),FRST%(I),LST%(I),RFL%(5*I),NXT%(5*I)
100 '
110 ' RESERVED WORDS
120 '
130 DATA ABS,AND,ASC,AS,ATN,AUTO,CDBL,CHR$,CINT,CLEAR,CLOSE,CONSOLE,CONT
140 DATA COS,CSNG,CVD,CVI,CVS,DATA
150 DATA DEFDBL,DEFINT,DEFSNG,DEFSTR,DEFUSR,DEF,DELETE,DIM,DSKI$,DSKO$,DSKF
160 DATA EDIT,ELSE,END,EOF,EQV,ERASE,ERL,ERR,EXP,FIELD,FILES,FIX,FOR
170 DATA FRE,GET,GOSUB,GOTO,HEX$
180 DATA IF,IMP,INPUT,INP,INSTR,INT,KILL,LEFT$,LEN,LET,LINE
190 DATA LIST,LLIST,LOAD,LOC,LOF,LOG,LPRINT,LSET,MERGE,MID$,MKD$,MKI$
200 DATA MKS$,MOD,MOUNT,NAME,NEW,NEXT,NOT,NULL,OCT$,ON,OPEN,OR,OUT
210 DATA PEEK,POKE,POS,PRINT,PUT
220 DATA READ,REM,RENUM,RESET,RESTORE,RESUME,RETURN,RIGHT$,RND,RSET,RUN
230 DATA SAVE,SGN,SIN,SPACE$,SPC(,SQR,STEP,STOP,STR$,STRING$,SWAP
240 DATA TAB(,TAN,THEN,TO,TROFF,TRON,UNLOAD
250 DATA USING,USR,VAL,VARPTR,WAIT,WIDTH,XOR,"\"
260 '
270 'FILL ARRAY WITH RESERVED WORDS
280 '
290 RW=0
300 READ RW$
310 RW=RW+1:RW$(RW)=RW$:IF RW$="\" THEN 350
320 I=ASC(RW$)-ASC("A"):IF PT%(I)=0 THEN PT%(I)=RW
330 GOTO 300
340 '
350 FOR I=0 TO 25:IF PT%(I)=0 THEN PT%(I)=RW
360 NEXT
370 '
380 'GET LIST OF FILE NAMES
390 '
400 FX=0
410 PRINT:PRINT " ASCII SAVED PROGRAM #";FX+1;" = ";:LINE INPUT L$
420 IF L$="" THEN IF FX<1 THEN 570 ELSE 480
430 IF INSTR(L$,".")=0 THEN L$=L$+".BAS"
440 REM NAME L$ AS L$
450 FX=FX+1:F$(FX)=L$
460 GOTO 410
470 '
480 PRINT:INPUT"DATE = ";D$
490 PRINT:INPUT"1) CROSS REFERENCE   2) LIST   3) BOTH ";M
500 '
510 'PROCESS LIST OF FILE NAMES
520 '
530 FOR F=1 TO FX
540 CLOSE
541 OPEN"I",1,F$(F)
542 PRG$="'"+F$(F)+"'  -  "+D$:GOSUB 610
550 NEXT
560 LPRINT STRING$(65-LZ,CHR$(10))
570 END
580 '
590 'INITIALIZE FOR CROSS REFERENCE
600 '
610 LC=0:BC=0:PZ=0:V$="":C$="":VC=91:RC=-1
620 FOR I=0 TO 91:VNXT%(I)=-1:NEXT
630 IF M>1 THEN GOSUB 1520
640 '
650 '   INPUT LINE & EXTRACT LINE#
660 '
670 IF EOF(1) THEN 1200
680 LINE INPUT #1,L$
681 IF M>1 THEN GOSUB 1430:IF M=2 THEN 670
690 LG=LEN(L$):BRNCH=0:ER$="":LC=LC+1:BC=BC+LG
700 LP=INSTR(L$," "):LN=VAL(LEFT$(L$,LP)):PRINT LN,
710 IF LN>32767 THEN LN=LN-65536!
720 '
730 '   PARSE REST OF LINE
740 '
750 LP=LP+1:IF LP>LG THEN GOSUB 1010:GOTO 670
760 C$=MID$(L$,LP,1)
770 IF C$>="A" AND C$<="Z" THEN 890 ELSE IF C$>="0" AND C$<="9" THEN 1150
780 IF C$=" " THEN 750 ELSE IF C$<>"," THEN BRNCH=0
790 IF C$=CHR$(34) THEN GOSUB 1010:LP=INSTR(LP+1,L$,C$):IF LP>0 THEN 750 ELSE 670
800 IF C$="\" THEN GOSUB 1010:GOTO 670
810 IF C$="&" THEN GOSUB 1010 :V$=C$:GOTO 750
820 IF C$="$" OR C$="!" OR C$="%" OR C$="#" THEN GOSUB 1130:GOTO 750
830 IF C$="(" THEN GOSUB 1130
840 GOSUB 1010:IF C$<>"," THEN ER$=""
850 GOTO 750
860 '
870 '   TEST FOR COMMAND
880 '
890 C=ASC(C$):P=PT%(C-ASC("A")):BRNCH=0
900 IF C<ASC(RW$(P)) THEN 1160
910 IF INSTR(LP,L$,RW$(P))<>LP THEN P=P+1:GOTO 900
920 GOSUB 1010:RW$=RW$(P)
930 IF RW$="DATA" THEN LP=INSTR(LP,L$,":"):IF LP>0 THEN 750 ELSE 670
940 IF RW$="REM" THEN 670
950 IF RW$="GOTO" OR RW$="GOSUB" OR RW$="THEN" OR RW$="ELSE" OR RW$="RESUME" THEN BRNCH=1
960 IF RW$="ERASE" THEN ER$="(" ELSE ER$=""
970 LP=LP+LEN(RW$)-1:GOTO 750
980 '
990 '  END VARIABLE
1000 '
1010 IF V$="" THEN RETURN
1020 IF V$>="A" THEN V$=V$+ER$:C=ASC(V$)+1 ELSE IF V$>="0" THEN V$=RIGHT$("    "+V$,5):C=VAL(LEFT$(V$,2)) ELSE 1090
1030 IL=-1:I=C
1040 IF V$>VV$(I) THEN IL=I:I=VNXT%(I):IF I>0 THEN 1040 ELSE 1060
1050 IF V$=VV$(I) THEN J=LST%(I-91):IF RFL%(J)=LN THEN 1090 ELSE RC=RC+1:NXT%(J)=RC:GOTO 1080
1060 VC=VC+1:IF IL>=0 THEN VNXT%(IL)=VC
1070 VV$(VC)=V$:VNXT%(VC)=I:RC=RC+1:FRST%(VC-91)=RC:I=VC
1080 RFL%(RC)=LN:NXT%(RC)=-1:LST%(I-91)=RC
1090 V$="":RETURN
1100 '
1110 '  EXPAND VARIABLE
1120 '
1130 IF V$<>"" THEN V$=V$+C$
1140 RETURN
1150 IF V$="" AND BRNCH=0 THEN 750
1160 V$=V$+C$:GOTO 750
1170 '
1180 '  LIST VARIABLES
1190 '
1200 IF M=2 THEN RETURN
1210 PZ=0:GOSUB 1520
1220 FOR J=0 TO 91:V=J
1230 V=VNXT%(V):IF V<0 THEN 1340
1240 IF LZ>56 THEN GOSUB 1400 ELSE SZ=SZ+1:IF SZ=3 THEN GOSUB 1410
1250 RZ=0:I=FRST%(V-91):LPRINT VV$(V);
1260 IF RZ=0 THEN LPRINT TAB(16);
1270 LN=RFL%(I):IF LN<0 THEN LN=LN+65536!
1280 LPRINT USING"    #####";LN,
1290 RZ=RZ+1
1300 IF RZ>6 THEN RZ=0:LPRINT:LZ=LZ+1:IF LZ>56 THEN GOSUB 1400
1310 I=NXT%(I):IF I>0 THEN 1260
1320 IF RZ>0 THEN LPRINT:LZ=LZ+1
1330 GOTO 1230
1340 NEXT J
1350 '
1360 LPRINT STRING$(80,"=")
1370 LPRINT"LINES:";LC;"    BYTES:";BC;"    SYMBOLS:";VC-91;" REFERENCES:";RC+1
1380 LZ=LZ+2:RETURN
1390 '
1400 GOSUB 1520:LPRINT"SYMBOL";TAB(20);"REFERENCE LINE":LZ=LZ+1
1410 LPRINT STRING$(80,"-"):LZ=LZ+1:SZ=0:RETURN
1420 '
1430 X=1
1440 IF LZ>60 OR RIGHT$(L$,3)="'PG" THEN GOSUB 1520
1450 Y=INSTR(X,L$,CHR$(10)):IF Y>0 THEN LPRINT MID$(L$,X,Y-X):LZ=LZ+1:X=Y+1:GOTO 1450
1460 LPRINT MID$(L$,X,LW):LZ=LZ+1:X=X+LW:IF X<LEN(L$) THEN 1460 ELSE RETURN
1470 '
1480 IF ERR=53 THEN PRINT:PRINT"FILE NOT FOUND":RESUME 410
1490 IF ERR=58 THEN RESUME 450
1500 ON ERROR GOTO 0
1501 IF ERL = 541 THEN PRINT:PRINT"FILE NOT FOUND":RESUME 410
1502 IF ERL = 680 THEN RESUME 1200
1503 PRINT "ERROR #";ERR;" ON LINE";ERL:STOP
1510 '
1520 LPRINT STRING$(65-LZ,CHR$(10))
1530 PZ=PZ+1:LPRINT TAB(72);"PG#";PZ
1540 LPRINT PRG$:LPRINT
1550 LZ=3:RETURN
2000 REM ----------------------------------------------
2010 REM Commented out line 440 NAME L$ AS L$
2020 REM Broke line 540 into 540, 541 and 542 for ERROR handler
2030 REM Broke line 680 into 680 and 681 for ERROR handler
2040 REM Added 1501, 1502 and 1503 ERROR handler
2050 REM Changed 70 ON ERROR GOTO 1480 to 70 ON ERROR GOTO 1501
2060 REM Added semicolons to PRINT commands
2070 REM Renamed V$() to VV$() 
2080 REM Changed 90 I=400 to 90 I=4000
2999 END 

