100 REM  Version 1.9 February 05/86 Ian Cottrell
110 CLEAR
120 VER$="1.9":DATE$="February 05/86"
130 CLS$=CHR$(24):CLS$="":PRINT CLS$;:    REM  Clear Screen Code
140 E$=CHR$(27):REM  Escape Character
150 DIM PRNAME$(10)
160 PRINT TAB(29); "=== C R O S S R E F ==="
170 PRINT
180 PRINT TAB(19); "COPYRIGHT (C) 1980 BY ADVANCED INFORMATICS"
190 PRINT TAB(17); "LISTS ALL VARIABLES AND REFERENCE LINE NUMBERS"
200 PRINT
210 PRINT TAB((71-LEN(VER$)-LEN(DATE$))/2);"Version ";VER$;" ";DATE$
220 PRINT TAB(39); "by"
230 PRINT TAB(24); "Klaus Bartels and Ian Cottrell":PRINT
240 GOSUB 2450
250 ON P GOSUB 2140,2180,2220,2260,2300,2340,2380,2420,2442
260 LPRINT RP$;:REM  RESET PRINTER IF POSSIBLE
270 DEFINT I-J:LW=132
280 ON ERROR GOTO 1950
290 DIM RW$(150),PT%(25),F$(10)
300 DIM VNXT%(490),V$(490),FRST%(400),LST%(400),RFL%(2000),NXT%(2000)
310 '
320 '  RESERVED WORDS
330 '
340 DATA ABS,ALL,AND,ASC,AS,ATN,AUTO,BASE
350 DATA CALL,CDBL,CHAIN,CHR$,CINT,CLEAR,CLOSE,COMMON,CONSOLE,CONT
360 DATA COS,CSAVE,CSNG,CVD,CVI,CVS
370 DATA DATA,DEFDBL,DEFINT,DEFSNG,DEFSTR,DEFUSR,DEF
380 DATA DELETE,DIM,DSKI$,DSKO$,DSKF
390 DATA EDIT,ELSE,END,EOF,EQV,ERASE,ERL,ERROR,ERR,EXP
400 DATA FIELD#,FIELD,FILES,FIX,FN,FOR,FRE
410 DATA GET,GOSUB,GOTO,HEX$
420 DATA IF,IMP,INKEY$,INPUT#,INPUT$,INPUT,INP,INSTR,INT,KILL
430 DATA LEFT$,LEN,LET,LINE,LIST,LLIST,LOAD,LOC,LOF,LOG,LPOS,LPRINT,LSET
440 DATA MERGE,MID$,MKD$,MKI$,MKS$,MOD,MOUNT
450 DATA NAME,NEW,NEXT,NOT,NULL,OCT$,ON,OPEN,OPTION,OR,OUT
460 DATA PEEK,POKE,POS,PRINT#,PRINT,PUT
470 DATA RANDOMIZE,READ,REM,REMOVE,RENUM,RESET,RESTORE,RESUME
480 DATA RETURN,RIGHT$,RND,RSET,RUN
490 DATA SAVE,SGN,SIN,SPACE$,SPC,SQR,STEP,STOP,STR$,STRING$,SWAP,SYSTEM
500 DATA TAB,TAN,THEN,TO,TROFF,TRON,UNLOAD,USING,USR
510 DATA VAL,VARPTR,WAIT,WEND,WHILE,WIDTH,WRITE#,WRITE,XOR,"\"
520 '
530 ' FILL ARRAY WITH RESERVED WORDS
540 '
550 RESTORE 340
560 RW=0
570 READ RW$
580 RW=RW+1:RW$(RW)=RW$:IF RW$="\" THEN 620
590 I=ASC(RW$)-ASC("A"):IF PT%(I)=0 THEN PT%(I)=RW
600 GOTO 570
610 '
620 FOR I=0 TO 25:IF PT%(I)=0 THEN PT%(I)=RW
630 NEXT
640 '
650 '  GET LIST OF FILE NAMES
660 '
670 FX=0:PRINT CLS$
680 PRINT:PRINT "ASCII SAVE PROGRAM #"; FX+1; " = ";:LINE INPUT L$
690 IF L$="" THEN IF FX<1 THEN 910 ELSE 750
700 IF INSTR(L$,".")=0 THEN L$=L$+".BAS"
710 REM NAME L$ AS L$
720 FX=FX+1:F$(FX)=L$
730 GOTO 680
740 '
750 PRINT:INPUT "DATE = ",D$
760 PRINT:INPUT "1)  CROSS REFERENCE    2)  LIST    3)  BOTH ";M
770 '
780 ' PROCESS LIST OF FILE NAMES
790 '
800 PRINT CLS$
810 FOR IDENT=1 TO FX
820  PRINT TAB(18);"XREF FILE ";F$(IDENT)
830 NEXT IDENT
840 PRINT
850 FOR F=1 TO FX
860 CLOSE:OPEN "I",1,F$(F):PRG$="'"+F$(F)+"' - "+D$
870 PRINT "CROSS-REF RUN LIST OF : ";PRG$
880 GOSUB 950
890 NEXT
900 LPRINT FF$
910 END
920 '
930 '  INITIALIZE FOR CROSS REFERENCE
940 '
950 LC=0:BC=0:PZ=0:V$="":C$="":VC=91:RC=-1:PZ=0
960 FOR I=0 TO 91:VNXT%(I)=-1:NEXT
970 IF M>1 THEN GOSUB 1990
980 '
990 '  INPUT LINE AND EXTRACT LINE NUMBER
1000 '
1010 IF EOF(1) THEN 1660
1020 LINE INPUT #1,L$:IF M>1 THEN GOSUB 1890:IF M=2 THEN 1010
1030 LG=LEN(L$):BRNCH=0:ER$="":LC=LC+1:BC=BC+LG
1040 GOSUB 2070
1050 PRINT "LEN=";LG;TAB(10);LEFT$(L$,65);TAB(78);"<"
1060  IF LN<10 THEN LP=2:GOTO 1110
1070   IF LN<100 THEN LP=3:GOTO 1110
1080    IF LN<1000 THEN LP=4:GOTO 1110
1090     IF LN<10000 THEN LP=5:GOTO 1110
1100 LP=6
1110 IF LN>32767 THEN LN=LN-65536!
1120 '
1130 '  PARSE REST OF LINE
1140 '
1150 LP=LP+1:IF LP>LG THEN GOSUB 1470:GOTO 1010
1160 C$=MID$(L$,LP,1)
1170 IF C$=CHR$(10) THEN LZ=LZ+1
1180 IF C$>="A" AND C$<="Z" THEN 1300 ELSE IF C$>="0" AND C$<="9" THEN 1610
1190 IF C$=" " THEN 1200 ELSE IF C$<>"," THEN BRNCH=0
1200 IF C$=CHR$(34) THEN GOSUB 1470:LP=INSTR(LP+1,L$,C$):IF LP>0 THEN 1150 ELSE 1010
1210 IF C$="'" THEN GOSUB 1470:GOTO 1010
1220 IF C$="&" THEN GOSUB 1470:V$=C$:GOTO 1150
1230 IF C$="$" OR C$="!" OR C$="%" OR C$="#" THEN GOSUB 1590:GOTO 1150
1240 IF C$="(" THEN GOSUB 1590
1250 GOSUB 1470:IF C$<>"," THEN ER$=""
1260 GOTO 1150
1270 '
1280 '  TEST FOR COMMAND
1290 '
1300 C=ASC(C$):P=PT%(C-ASC("A")):BRNCH=0
1310 IF C<ASC(RW$(P)) THEN 1620
1320 IF INSTR(LP,L$,RW$(P))<>LP THEN P=P+1:GOTO 1310
1330 N$=MID$(L$,LP+LEN(RW$(P)),1)
1340 N=VAL(N$)
1350 IF N>47 AND N<58 AND N>64 AND N<90 AND N>94 THEN P=P+1:GOTO 1310
1360 T$=MID$(L$,LP-1,1)
1370 IF T$>="A" AND T$<="Z" THEN 1620
1372 IF T$>="0" AND T$<="9" THEN 1620
1374 IF T$="." THEN 1620
1380 GOSUB 1470:RW$=RW$(P)
1390 IF RW$="DATA" THEN LP=INSTR(LP,L$,":"):IF LP>0 THEN 1150 ELSE 1010
1400 IF RW$="REM" THEN 1010
1410 IF RW$="GOTO" OR RW$="GOSUB" OR RW$="THEN" OR RW$="ELSE" OR RW$="RESUME" THEN BRNCH=1
1420 IF RW$="ERASE" THEN ER$="(" ELSE ER$=""
1430 LP=LP+LEN(RW$)-1:GOTO 1150
1440 '
1450 '  END VARIABLE
1460 '
1470 IF V$="" THEN RETURN
1480 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 1550
1490 IL=-1:I=C
1500 IF V$>V$(I) THEN IL=I:I=VNXT%(I):IF I>0 THEN 1500 ELSE 1520
1510 IF V$=V$(I) THEN J=LST%(I-91):IF RFL%(J)=LN THEN 1550 ELSE RC=RC+1:NXT%(J)=RC:GOTO 1540
1520 VC=VC+1:IF IL>=0 THEN VNXT%(IL)=VC
1530 V$(VC)=V$:VNXT%(VC)=I:RC=RC+1:FRST%(VC-91)=RC:I=VC
1540 RFL%(RC)=LN:NXT%(RC)=-1:LST%(I-91)=RC
1550 V$="":RETURN
1560 '
1570 '  EXPAND VARIABLE
1580 '
1590 IF V$<>"" THEN V$=V$+C$
1600 RETURN
1610 IF V$="" AND BRNCH=0 THEN 1150
1620 V$=V$+C$:GOTO 1150
1630 '
1640 '  LIST VARIABLES
1650 '
1660 IF M=2 THEN RETURN
1670 GOSUB 1860
1680 FOR J=0 TO 91:V=J
1690 V=VNXT%(V):IF V<0 THEN 1800
1700 IF LZ>56 THEN GOSUB 1860 ELSE SZ=SZ+1:IF SZ=3 THEN GOSUB 1870
1710 RZ=0:I=FRST%(V-91):LPRINT TAB(10); V$(V);
1720 IF RZ=0 THEN LPRINT TAB(26);
1730 LN=RFL%(I):IF LN<0 THEN LN=LN+65536!
1740 LPRINT USING "    #####";LN,
1750 RZ=RZ+1
1760 IF RZ>10 THEN RZ=0:LPRINT:LZ=LZ+1:IF LZ>56 THEN GOSUB 1870
1770 I=NXT%(I):IF I>0 THEN 1720
1780 IF RZ>0 THEN LPRINT:LZ=LZ+1
1790 GOTO 1690
1800 NEXT J
1810 '
1820 LPRINT TAB(10); STRING$(122,"=")
1830 LPRINT TAB(10); "LINES: "; LC; "     BYTES: "; BC; "    SYMBOLS: "; VC-91; "    REFERENCES: "; RC+1
1840 LZ=LZ+2:RETURN
1850 '
1860 GOSUB 1990:LPRINT TAB(10); "SYMBOL"; TAB(30); "REFERENCE LINE":LZ=LZ+1
1870 LPRINT TAB(10); STRING$(122,"-"):LZ=LZ+1:SZ=0:RETURN
1880 '
1890 X=1
1900 IF LZ>60 THEN GOSUB 1990
1910 IF RIGHT$(L$,3)="'PG" THEN GOSUB 1990
1920 Y=INSTR(X,L$,CHR$(10)):IF Y>0 THEN LPRINT TAB(10); MID$(L$,X,Y-X):LZ=LZ+1:IF ASC(MID$(L$,Y+1,1))=13 THEN X=Y+2 ELSE X=Y+1:GOTO 1920
1930 LPRINT TAB(10); MID$(L$,X,LW):LZ=LZ+1:X=X+LW:IF X<LEN(L$) THEN 1930 ELSE RETURN
1940 '
1950 IF ERR=53 THEN PRINT:PRINT "FILE NOT FOUND":RESUME 680
1960 IF ERR=58 THEN RESUME 720
1970 ON ERROR GOTO 0
1980 '
1990 LPRINT FF$;
2000 PZ=PZ+1
2010 LS=(58-LEN(PRG$)-6)
2020 LPRINT CMP$;
2030 LPRINT TAB(10);EXO$;PRG$;SPC(LS);
2040 LPRINT " Page ";PZ
2050 LPRINT EXF$:LPRINT
2060 LZ=4:RETURN
2070 NUM=0
2080 FOR II=1 TO LG
2090 IF MID$(L$,II,1)=" " THEN II=LG ELSE NUM=NUM+1
2100 NEXT II
2110 LN=VAL(LEFT$(L$,NUM))
2120 RETURN
2130 REM  QANTEX 7030 PRINTER
2140 EXO$=CHR$(14):EXF$=CHR$(15)
2150 CMP$=E$+"[4w":RP$=E$+"c":FF$=CHR$(12)
2160 RETURN
2170 REM  C. ITOH PROWRITER PRINTERS
2180 EXO$=CHR$(14):EXF$=CHR$(15)
2190 CMP$=E$+"Q":RP$="":FF$=CHR$(12)
2200 RETURN
2210 REM  EPSON MX-80/100 PRINTERS
2220 EXO$=CHR$(14):EXF$=CHR$(20)
2230 CMP$=CHR$(15):RP$="":FF$=CHR$(12)
2240 RETURN
2250 REM  STAR MICRONICS GEMINI PRINTER
2260 EXO$=E$+CHR$(14):EXF$=CHR$(20)
2270 CMP$=E$+"B"+CHR$(3):RP$="":FF$=CHR$(12)
2280 RETURN
2290 REM  GENICOM 3400 PRINTER
2300 EXO$=E$+CHR$(14):EXF$=CHR$(20)
2310 CMP$=E$+"[;43 G":RP$="":FF$=CHR$(12)
2320 RETURN
2330 REM  CITIZEN MSP-10/15/20/25 PRINTERS
2340 EXO$=CHR$(14):EXF$=CHR$(20)
2350 CMP$=CHR$(15):RP$=E$+"@":FF$=CHR$(12)
2360 RETURN
2370 REM  PANASONIC KX-P1090 PRINTER
2380 EXO$=CHR$(14):EXF$=CHR$(20)
2390 CMP$=CHR$(15):RP$=E$+"@":FF$=CHR$(12)
2400 RETURN
2410 REM  FACIT 4510 PRINTER
2420 EXO$=CHR$(30):EXF$=CHR$(31)
2430 CMP$=E$+"7":RP$=E$+"0":FF$=CHR$(12)
2440 RETURN
2442 REM  PLAIN TEXT
2444 EXO$="":EXF$=""
2446 CMP$="":RP$="":FF$=""
2448 RETURN
2450 REM  Read names of available printers
2460 RESTORE 2500
2470 FOR M=1 TO 10
2480	READ PRNAME$(M)
2490 NEXT M
2500 DATA "Qantex 7030","C. Itoh Prowriter","Epson MX/FX-80/100"
2510 DATA "Star Micronics Gemini","GE Genicom 3400","Citizen MSP-10/15/20/25"
2520 DATA "Panasonic KX-P1090","Facit 4510", "PLAIN TEXT",""
2530 REM  Ask for desired printer
2540 PRINT
2550 PRINT "> This program presently supports the following printers:":PRINT
2560 FOR I=1 TO 10 STEP 2
2570	PRINT "       "; CHR$(I+48); ")  "; PRNAME$(I); TAB(41); CHR$(I+1+48); ")  "; PRNAME$(I+1)
2580 NEXT I
2590 PRINT:PRINT "> Please select the printer you wish to use .... ";
2600 INPUT R$:IF R$="" THEN 2600 ELSE PRINT R$
2610 P=VAL(R$)
2620 IF P<1 OR P>9 THEN 2590
2630 RETURN
3000 REM -------------------------------------------
3010 REM Added PLAIN TEXT printer
3999 END
