1 '     XREFMOD.BAS modified from XREF.BAS and PRINTER.BAS from BALTIMORE
2 '
3 '     PC VOL. 1.45 from the PC^3 Software Library by
4 '
5 '     Michael Csontos, 3228 Livonia Center Road, Lima, New York 14485
6 '
7 '     August 18, 1982
8 '
9 '
10 LPRINT CHR$(27) "@";
20 LPRINT CHR$(27);"C";CHR$(0);CHR$(11);      'ESC,FORM LENGTH,11 INCHES
30 LPRINT CHR$(15);CHR$(27);CHR$(65);CHR$(9);'COMPRESSED,ESC,LINE FEED,9/72 IN.
50 PRINT "Disk A":FILES "a:*.*":PRINT:PRINT "Disk B":FILES "b:*.*"
60 WIDTH "lpt1:",255
180 PRINT :PRINT "XREF Lists all variables & referenced line #'s as well as the program."
200 PRINT "Initializing_______ ENTER Filename BY   filespec  OR   b:filespec"
220 PRINT "Operate ENTER when last program to be XREF has been entered"
250 DEFINT I-J:LW = 130
260 ON ERROR GOTO 1700
270 DIM RW$(149),PT%(25),F$(20)
280 I = 400: DIM VNXT%(I + 90),V$(I + 90),FRST%(I),LST%(I),RFL%(5 * I),NXT%(5 * I)
320 DATA ABS,AND,ASC,AS,ATN,AUTO,BEEP,CDBL,CHAIN,CHR$,CINT,CIRCLE,CLEAR,CLOSE,CLS,COLOR,COMMON,CONT
330 DATA COS,CSNC,CSRLIN,CVD,CVI,CVS,DATA,DATE$,DEF
340 DATA DEFDBL,DEFINT,DEFSNG,DEFSTR,DELETE,DIM,DRAW
350 DATA EDIT,ELSE,END,EOF,EQV,ERASE,ERL,ERROR,EXP,FIELD,FILES,FIX,FN,FOR
360 DATA FRE,GET,GOSUB,GOTO,HEX$
370 DATA IF,IMP,INKEY$,INPUT,INSTR,INT,KEY,KILL,LEFT$,LEN,LET,LINE
380 DATA LIST,LLIST,LOAD,LOCATE,LOF,LOG,LPOS,LPRINT,LSET,MERGE,MID$,MKD$,MKI$
390 DATA MKS$,MOD,MOTOR,NAME,NEW,NEXT,NOT,OCT$,OFF,ON,OPEN,OPTION,OR,OUT
400 DATA PAINT,PEEK,PEN,PLAY,POINT,POKE,POS,PRESET,PRINT,PSET,PUT
410 DATA RANDOMIZE,READ,REM,RENUM,RESET,RESTORE,RESUME,RETURN,RIGHT$,RND,RSET,RUN
420 DATA SAVE,SCREEN,SGN,SIN,SOUND,SPACE$,SPC(,SQR,STEP,STICK,STOP,STR$,STRIG,STRING$,SWAP,SYSTEM
430 DATA TAB(,TAN,THEN,TIME$,TO,TROFF,TRON
440 DATA USING,USR,VAL,VARPTR,WAIT,WEND,WHILE,WIDTH,WRITE,XOR,"\"
480 RW = 0
490 READ RW$
500 RW = RW + 1: RW$(RW) = RW$: IF RW$ = "\" THEN 550
510 I = ASC(RW$) - ASC("A"): IF PT%(I) = 0 THEN PT%(I) = RW
530 GOTO 490
550 FOR I = 0 TO 25: IF PT%(I) = 0 THEN PT%(I) = RW
560 NEXT
600 FX = 0
610 PRINT :PRINT " ASCII saved program # " FX + 1 " = ";:LINE INPUT L$
612 FOR X=1 TO LEN(L$)' ------- UPPERFY from PRINTER.BAS -----------
614 XC$=MID$(L$,X,1)
616 IF "a" <= XC$ AND XC$ <= "z" THEN MID$(L$,X,1) =CHR$(ASC(XC$)-32)
618 NEXT X'     --------------------------------------------
620 IF L$ = "" THEN IF FX < 1 THEN 780 ELSE 680
630 IF INSTR(L$,".") = 0 THEN L$ = L$ + ".bas"
640 NAME L$ AS L$
650 FX = FX + 1: F$(FX) = L$
660 GOTO 610
680 D$ = DATE$:T$ = TIME$
690 PRINT : INPUT"1) cross reference   2) list   3)both ";M
695 PRINT "Current line being parsed"
730 FOR F = 1 TO FX
740 CLOSE: OPEN"I",1,F$(F):PRG$ = CHR$(34)+F$(F)+CHR$(34)+" - Printed on "+ D$+" at "+T$: GOSUB 820
745 LPRINT CHR$(12)      'form feed      LPRINT STRING$(65 - LZ,CHR$(10))
750 NEXT
780 END
820 LC = 0: BC = 0: PZ = 0: V$ = "": C$ = "": VC = 91: RC = -1:PAGE.LEN = 80
830 FOR I = 0 TO 91: VNXT%(I) = -1: NEXT I
840 IF M > 1 THEN GOSUB 1760
880 IF EOF(1) THEN 1420
890 LINE INPUT#1,L$: IF M > 1 THEN GOSUB 1650: IF M = 2 THEN 880
900 LG = LEN(L$): BRNCH = 0: ER$ = "": LC = LC + 1: BC = BC + LG
910 LP = INSTR(L$," "): LN = VAL(LEFT$(L$,LP)): PRINT LN;
920 IF LN > 32767 THEN LN = LN - 65536!
960 LP = LP + 1: IF LP > LG THEN GOSUB 1220: GOTO 880
970 C$ = MID$(L$,LP,1)
980 IF C$ >= "A" AND C$ <= "Z" THEN 1100 ELSE IF C$ >= "0" AND C$ <= "9" THEN 1360
990 IF C$ = " " THEN GOSUB 1220: GOTO 960 ELSE IF C$ <> ", " THEN BRNCH = 0
1000 IF C$ = CHR$(34) THEN GOSUB 1220: LP = INSTR(LP + 1,L$,C$): IF LP > 0 THEN 960 ELSE 880
1010 IF C$ = "'" THEN GOSUB 1220: GOTO 880
1020 IF C$ = "&" THEN GOSUB 1220: V$ = C$: GOTO 960
1030 IF C$ = "$" OR C$ = "!" OR C$ = "%" OR C$ = "#" THEN GOSUB 1340: GOTO 960
1040 IF C$ = "(" THEN GOSUB 1340
1050 GOSUB 1220: IF C$ <> ", " THEN ER$ = ""
1060 GOTO 960
1100 IF V$ > "" THEN 1370 ELSE C = ASC(C$): P = PT%(C - ASC("A")): BRNCH = 0
1110 IF C < ASC(RW$(P)) THEN 1370
1120 IF INSTR(LP,L$,RW$(P)) <> LP THEN P = P + 1: GOTO 1110
1130 GOSUB 1220: RW$ = RW$(P)
1140 IF RW$ = "DATA" THEN LP = INSTR(LP,L$,": "): IF LP > 0 THEN 960 ELSE 880
1150 IF RW$ = "REM" THEN 880
1160 IF RW$ = "GOTO" OR RW$ = "GOSUB" OR RW$ = "THEN" OR RW$ = "ELSE" OR RW$ = "RESUME" THEN BRNCH = 1
1170 IF RW$ = "ERASE" THEN ER$ = "(" ELSE ER$ = ""
1180 LP = LP + LEN(RW$) - 1: GOTO 960
1220 IF V$ = "" THEN RETURN
1230 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 1300
1240 IL = -1: I = C
1250 IF V$ > V$(I) THEN IL = I: I = VNXT%(I): IF I > 0 THEN 1250 ELSE 1270
1260 IF V$ = V$(I) THEN J = LST%(I-91): IF RFL%(J) = LN THEN 1300 ELSE RC = RC + 1: NXT%(J) = RC: GOTO 1290
1270 VC = VC + 1: IF IL >= 0 THEN VNXT%(IL) = VC
1280 V$(VC) = V$: VNXT%(VC) = I: RC = RC + 1: FRST%(VC - 91) = RC: I = VC
1290 RFL%(RC) = LN: NXT%(RC) = -1: LST%(I - 91) = RC
1300 V$ = "": RETURN
1340 IF V$ <> "" THEN V$ = V$ + C$
1350 RETURN
1360 IF V$ = "" AND BRNCH = 0 THEN 960
1370 V$ = V$ + C$: GOTO 960
1420 IF M = 2 THEN RETURN
1422 IF M=1 THEN PZ=0
1424 SINGPG=0:IF M=3 THEN LPRINT:LPRINT:LZ=LZ+2:SINGPG=1
1430 GOSUB 1790           'print page no and header
1440 FOR J = 0 TO 91: V = J
1450 V = VNXT%(V): IF V < 0 THEN 1560
1460 IF LZ > PAGE.LEN THEN GOSUB 1620 ELSE SZ = SZ + 1: IF SZ = 3 THEN GOSUB 1630
1470 RZ = 0: I = FRST%(V - 91): LPRINT V$(V);
1480 IF RZ = 0 THEN LPRINT TAB(16);
1490 LN = RFL%(I): IF LN < 0 THEN LN = LN + 65536!
1500 LPRINT USING "    #####";LN;
1510 RZ = RZ + 1
1520 IF RZ > 12 THEN RZ = 0: LPRINT: LZ = LZ + 1: IF LZ > PAGE.LEN THEN GOSUB 1620
1530 I = NXT%(I): IF I > 0 THEN 1480
1540 IF RZ > 0 THEN LPRINT: LZ = LZ + 1
1550 GOTO 1450
1560 NEXT J
1580 LPRINT STRING$(130, "=")
1590 LPRINT "lines: ";LC;"    bytes: ";BC;"     symbols: ";VC - 91; "references: ";RC + 1
1600 LZ = LZ + 2: RETURN
1620 GOSUB 1750: LPRINT "symbol/line no. ";TAB(20);"reference line":LPRINT STRING$(130,"-"):LZ = LZ + 1
1630 LPRINT :LZ = LZ + 1: SZ = 0: RETURN
1650 X = 1
1660 IF LZ > PAGE.LEN OR RIGHT$(L$,3) = "'PG" THEN GOSUB 1750
1670 Y = INSTR(X,L$,CHR$(10)): IF Y > 0 THEN LPRINT MID$(L$,X,Y - X): LZ = LZ + 1: X = Y + 1: GOTO 1670
1680 LPRINT MID$(L$,X,LW):LZ = LZ + 1: X = X + LW: IF X < LEN(L$) THEN 1680 ELSE RETURN
1700 IF ERR = 53 THEN PRINT:PRINT "file not found": RESUME 610
1710 IF ERR = 58 THEN RESUME 650
1720 IF ERR = 24 THEN RESUME          ' device timeout occurred, continue
1730 ON ERROR GOTO 0
1750 LPRINT CHR$(12)       'form feed     LPRINT STRING$(65 - LZ,CHR$(10))
1760 IF SINGPG=1 THEN LPRINT :SINGPG=0:RETURN ELSE PZ = PZ + 1
1770 LPRINT  CHR$(14) PRG$  "     PAGE" PZ: LPRINT
1780 LZ = 3 : RETURN
1790 GOSUB 1760: LPRINT "symbol/line no. ";TAB(20);"reference line":LZ = LZ + 1
1800 LPRINT STRING$(130,"-"):LZ = LZ + 1: SZ = 0: RETURN
2000 '  SAVE"a:xrefmod.sys",a