4  'SEE INTERFACE AGE -- JUNE 1981 -- PAGE 98
6  '
7 '
8 ' MODIFIED FOR BASIC/BASICA by Lee Anderson 9/01/82
9 '
10 CLS:LOCATE 8,1: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"
50 '
51 DIM MONTH$(12)
52 FOR J = 1 TO 12: READ MONTH$(J): NEXT J
53 DATA Jan, Feb, Mar, Apr, May, Jun, Jul, Aug, Sep, Oct, Nov, Dec
54 D$ = MID$(DATE$,4,3) + MONTH$(VAL(MID$(DATE$,1,2))) + "-" + MID$(DATE$,9,2)
60 DEFINT I-J:LW=80
70 ON ERROR GOTO 1480
80 DIM RW$(158),PT%(25),F$(10)
90 I=400:DIM VNXT%(490),V$(490),FRST%(400),LST%(400),RFL%(2000),NXT%(2000)
100 '
110 ' RESERVED WORDS
120 '
130 DATA ABS,AND,AS,ASC,ATN,AUTO,BASE,BEEP,BLOAD,BSAVE
131 DATA CDBL,CHAIN,CHR$,CINT,CIRCLE
135 DATA CLEAR,CLOSE,CLS,COLOR,COM,COMMON,CONT
140 DATA COS,CSNG,CVD,CVI,CVS,DATA,DATE$,DEF
150 DATA DEFDBL,DEFINT,DEFSNG,DEFSTR,DEFUSR,DEF,DIM,DRAW
160 DATA EDIT,ELSE,END,EOF,EQV,ERASE,ERL,ERR,ERROR,EXP,FIELD,FILES,FIX,FOR
170 DATA FRE,GET,GOSUB,GOTO,HEX$
180 DATA IF,IMP,INKEY$,INPUT,INPUT#,INPUT$,INP,INSTR,INT,KEY,KILL,LEFT$,LEN,LET,LINE
190 DATA LIST,LLIST,LOAD,LOC,LOCATE,LOF,LOG,LPOS,LPRINT,LSET,MERGE,MID$,MKD$,MKI$
200 DATA MKS$,MOD,MOTOR,NAME,NEW,NEXT,NOT,OCT$,OFF,ON,OPEN,OPTION,OR,OUT
210 DATA PAINT,PEEK,PEN,PLAY,POKE,POS,PRESET,PRINT,PRINT#,PSET,PUT
220 DATA RANDOMIZE,READ,REM,RENUM,RESET,RESTORE,RESUME,RETURN,RIGHT$,RND,RSET,RUN
230 DATA SAVE,SCREEN,SGN,SIN,SOUND,SPACE$,SPC(,SQR,STEP,STOP,STR$
240 DATA STRIG,STRING$,SWAP,SYSTEM,TAB(,TAN,THEN,TIME$,TO,TROFF,TRON
250 DATA USING,USR,VAL,VARPTR,WAIT,WEND,WHILE,WIDTH,WRITE,WRITE#,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 NAME L$ AS L$
450 FX=FX+1:F$(FX)=L$
460 GOTO 410
470 '
480 '
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:OPEN"I",1,F$(F):PRG$="'"+F$(F)+"'  -  "+D$:GOSUB 610
550 NEXT
560 ' there was a form feed here but i thought it was not necessary
565 ON ERROR GOTO 0
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$: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
835 IF C$ = "." THEN GOSUB 1130: GOTO 750
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 CLP 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$)+1ELSE IF V$>="0"THEN V$=RIGHT$("    "+V$,5):C=VAL(LEFT$(V$,2)) ELSE 1090
1030 IL=-1:I=C
1040 IF V$>V$(I)THEN IL=I:I=VNXT%(I):IF I>0 THEN 1040 ELSE 1060
1050 IF V$=V$(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 V$(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 1400: SZ = -1
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 V$(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$(79,"=")
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$(79,"-"):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