Category : BASIC Source Code
Archive   : CROSSREF.ZIP
Filename : CROSSREF.BAS

 
Output of file : CROSSREF.BAS contained in archive : CROSSREF.ZIP
10 '******** "CROSSREF.BAS" ********
20 KEY OFF:CLS:SCREEN 0,0,0:DEFINT A-Z:OPTION BASE 1
30 DIM LIN$(2500)
40 DEF FNPAD$=RIGHT$(SPACE$(4)+STR$(LN!),5)
50 DEF FNCENTER(X$)=(76-LEN(X$))\2
60 T$="Cross Reference":LOCATE 1,FNCENTER(T$)
70 PRINT T$:PRINT:PRINT
80 PRINT "Program to be Cross Referenced must be in ASCII Format"
90 PRINT:INPUT "Enter [d:filespec.ext] : ",FIL$
100 OPEN FIL$ FOR INPUT AS #1
110 LINE INPUT #1,L$:CLOSE #1:IF ASC(L$)<49 OR ASC(L$)>57 THEN PRINT:PRINT FIL$ " is not an ASCII Program File.":END
120 PRINT:PRINT TAB(20);"1. Cross Reference of Branches"
130 PRINT TAB(20);"2. Cross Reference of Variables"
140 PRINT TAB(20);"3. Both Branches and Variables"
150 PRINT TAB(20);:INPUT " Your Choice: ",K:IF K<1 OR K>3 THEN 150
160 ON K GOTO 170,180,170
170 DIM BR$(10):FOR I=1 TO 10:READ BR$(I):NEXT:IF K=1 THEN 190
180 RESTORE 1090:DIM SY$(16),S$(188):FOR I=1 TO 16:READ SY:SY$(I) = CHR$(SY):NEXT:FOR I=1 TO 188:READ S$(I):NEXT
190 OPEN FIL$ FOR INPUT AS #1
200 PRINT:PRINT "Line Number being processed: ";:ROW=CSRLIN:COL=POS(0)
210 WHILE NOT EOF(1):LINE INPUT #1,L$: M=1: B=INSTR(M,L$," "): LN!=VAL(L$):LN$=FNPAD$:LOCATE ROW,COL:PRINT LN$
220 ' **** Eliminate string literals, DATA statements, and REMarks
230 P=INSTR(M,L$,CHR$(34)):IF P=0 THEN 260
240 M=P+1:P=INSTR(M,L$,CHR$(34)):IF P=0 THEN P=LEN(L$)
250 L$=LEFT$(L$,M-2)+" "+MID$(L$,P+1):GOTO 230:' Remove quotes
260 M=1:P=INSTR(M,L$,"DATA "):IF P=B+1 THEN 500 ELSE IF P THEN GOSUB 940
270 P=INSTR(M,L$,"REM "):IF P=B+1 THEN 500 ELSE IF P THEN GOSUB 940
280 P=INSTR(M,L$,"'"):IF P=B+1 THEN 500 ELSE IF P THEN GOSUB 940
290 IF K=2 THEN 390
300 ' **** Find branching and non-local return statements
310 FOR I=1 TO 10:M=1:MM=1
320 P=INSTR(M,L$,BR$(I)):IF P=0 THEN 370
330 M=P+LEN(BR$(I)):LN!=VAL(MID$(L$,M)):IF LN!=0 THEN 320
340 C$=FNPAD$+LN$:GOSUB 930:L=L+1:' Store C$ in array
350 IF I < 3 THEN GOSUB 760
360 GOTO 320
370 NEXT
380 IF K=1 THEN 500
390 L$=L$+" ": LL=LEN(L$)
400 ' **** Replace BASIC's special characters with spaces

410 FOR I=1 TO 16:P=B
420 M=P:P=INSTR(M,L$,SY$(I)):IF P>0 THEN MID$(L$,P,1)=" ": GOTO 420
430 NEXT:P=B
440 ' **** Find Variables - Process of elimination
450 M=P:WHILE MID$(L$,M,1)=" ":M=M+1:WEND:IF M>LL THEN 500
460 P=INSTR(M,L$," "):IF ASC(MID$(L$,M,1))<65 THEN 450:' Bypass if it is a number
470 C$=MID$(L$,M,P-M):GOSUB 870:IF SW=0 THEN 450:' Bypass if it is a reserved word
480 IF LEN(C$)>15 THEN C$=LEFT$(C$,15):' Hack variable length to 15 characters
490 C$=C$+" "+LN$:GOSUB 930:GOTO 450:' It is a variable. Store in array and continue parsing
500 WEND:CLOSE:PRINT:PRINT "Sorting . . .":GOSUB 960:BEEP
510 PRINT:PRINT "Prepare Printer for Output - Press any key when ready";
520 DEF SEG=0:POKE 1050,PEEK(1052):' Clear keyboard buffer
530 IK$="":WHILE IK$="":IK$=INKEY$:WEND:DEF SEG
540 ' **** Print Results
550 IF K=2 THEN 600
560 HI=L:LO=1:TT$="Cross Reference of Branches in "+FIL$:B$="":Z=12
570 T$="Target Referencing Lines"
580 GOSUB 740:GOSUB 640:LPRINT CHR$(12);
590 IF K=1 THEN END
600 HI=N:LO=L+1:TT$="Cross Reference of Variables in "+FIL$:B$="":Z=17
610 T$="Variables Line Numbers"
620 GOSUB 740:GOSUB 640:LPRINT CHR$(12);
630 END
640 FOR Y=LO TO HI:IF LIN$(Y)=LIN$(Y+1) THEN 720
650 A$=LEFT$(LIN$(Y),LEN(LIN$(Y))-5)
660 IF A$<>B$ AND LC>56 THEN LPRINT CHR$(12);:GOSUB 740
670 IF A$<>B$ THEN B$=A$:LC=LC+2:LPRINT "":LPRINT"":LPRINT B$; TAB(Z);:X$=""
680 IF LPOS(0)<73 THEN 710
690 IF LC>56 THEN LPRINT CHR$(12);:GOSUB 740
700 LPRINT X$:LC=LC+1:LPRINT TAB(Z);:X$=""
710 LPRINT X$;RIGHT$(LIN$(Y),5);:X$=", "
720 NEXT:RETURN
730 ' **** Heading Routine
740 LC=5:LPRINT"":LPRINT TAB(FNCENTER(TT$));TT$:LPRINT"":LPRINT T$:LPRINT STRING$(Z-3,"-"); TAB(Z);STRING$(76-Z,"-");:RETURN
750 ' **** Test for ON...GOTO and ON...GOSUB
760 O=INSTR(MM,L$,"ON "):IF O>M OR O=0 THEN 850
770 MM=M:P=INSTR(O,L$,"ELSE "):PP=INSTR(O,L$,":")
780 IF P=0 AND PP=0 THEN P=LEN(L$):GOTO 810
790 IF P=0 THEN P=PP:GOTO 810
800 IF PP

810 TEMP$=LEFT$(L$,P)
820 P=INSTR(M,TEMP$,","):IF P=0 THEN 850 ELSE M=P+1
830 LN!=VAL(MID$(L$,M)):IF LN!=0 THEN 850
840 C$=FNPAD$+LN$:GOSUB 930:L=L+1:GOTO 820
850 RETURN
860 ' **** Binary Search
870 HI=188:LO=1:SW=0
880 IF LO > HI THEN SW=1:GOTO 920
890 MI=(HI+LO)\2
900 IF C$ > S$(MI) THEN LO=MI+1:GOTO 880
910 IF C$ < S$(MI) THEN HI=MI-1:GOTO 880
920 RETURN
930 N=N+1:LIN$(N)=C$:RETURN:' Store in array
940 L$=LEFT$(L$,P-1):RETURN:' Hack DATA and REMarks
950 ' **** Quick Sort
960 DIM ST(25,2)
970 SP=0: LO=1: HI=N:GOTO 1030
980 SWAP LIN$(PS),LIN$(LO):IF PS>HI-2 THEN HI=PS-1 ELSE IF PS 990 GOTO 1030
1000 FOR I=LO+1 TO HI: FOR J=LO TO I:IF LIN$(I) 1010 NEXT J,I
1020 IF SP=0 THEN RETURN ELSE LO=ST(SP,1):HI=ST(SP,2):SP=SP-1
1030 IF HI-LO<=9 THEN 1000 ELSE LS=LO:HS=HI+1:SWAP LIN$(LO), LIN$(INT((HS-LS)/2)+LO)
1040 IF HS=LS+1 THEN PS=LS:GOTO 980 ELSE LS=LS+1:IF LIN$(LS)<=LIN$(LO) THEN 1060
1050 IF HS=LS+1 THEN PS=LS-1:GOTO 980 ELSE HS=HS-1:IF LIN$(HS)>=LIN$(LO) THEN 1050 ELSE SWAP LIN$(LS),LIN$(HS):GOTO 1040
1060 IF HS=LS+1 THEN PS=LS:GOTO 980 ELSE HS=HS-1:IF LIN$(HS)>=LIN$(LO) THEN 1040
1070 IF HS=LS+1 THEN PS=HS:GOTO 980 ELSE LS=LS+1:IF LIN$(LS)<=LIN$(LO) THEN 1070 ELSE SWAP LIN$(LS),LIN$(HS):GOTO 1060
1080 DATA "GOSUB ","GOTO ","ELSE ","THEN ","RESTORE ","RESUME ","RETURN ","RUN ","ERL=","ERL ="
1090 DATA 40,41,43,45,42,47,58,59,44,60,61,62,63,92,94,95
1100 DATA ABS, ALL, AND, APPEND, AS, ASC, ATN, AUTO, BASE, BEEP, BLOAD, BSAVE, CALL, CDBL, CHAIN, CHDIR, CHR$, CINT, CIRCLE, CLEAR, CLOSE, CLS, COLOR, COM, COMMON, CONT, COS, CSNG
1110 DATA CSRLIN, CVD, CVI, CVS, DATE$, DEF, DEFDBL, DEFINT, DEFSNG, DEFSTR, DELETE, DIM, DRAW, EDIT, ELSE, END, ENVIRON, ENVIRON$, EOF, EQV, ERASE, ERDEV, ERDEV$, ERL, ERR
1120 DATA ERROR, EXP, FIELD, FILES, FIX, FOR, FRE, GET, GOSUB, GOTO, HEX$, IF, IMP, INKEY$, INP, INPUT, INPUT#, INPUT$, INSTR, INT, INTER$, IOCTL, IOCTL$, KEY, KEY$
1130 DATA KILL, LEFT$, LEN, LET, LINE, LIST, LLIST, LOAD, LOC, LOCATE, LOF, LOG, LPOS, LPRINT, LSET, MERGE, MID$, MKDIR, MKD$, MKI$, MKS$, MOD, MOTOR, NAME, NEW
1140 DATA NEXT, NOT, OCT$, OFF, ON, OPEN, OPTION, OR, OUT, OUTPUT, PAINT, PEEK, PEN, PLAY, PMAP, POINT, POKE, POS, PRESET, PRINT, PRINT#, PSET, PUT, RANDOMIZE, READ
1150 DATA RENUM, RESET, RESTORE, RESUME, RETURN, RIGHT$, RMDIR, RND, RSET, RUN, SAVE, SCREEN, SEG, SGN, SHELL, SIN, SOUND, SPACE$, SPC, SQR, STEP, STICK, STOP, STR$, STRIG, STRING$
1160 DATA SWAP, SYSTEM, TAB, TAN, THEN, TIME$, TIMER, TO, TROFF, TRON, USING, USR, USR0, USR1, USR2, USR3, USR4, USR5, USR6, USR7, USR8, USR9
1170 DATA VAL, VARPTR, VARPTR$, VIEW, WAIT, WEND, WHILE, WIDTH, WINDOW, WRITE, WRITE#, XOR


  3 Responses to “Category : BASIC Source Code
Archive   : CROSSREF.ZIP
Filename : CROSSREF.BAS

  1. Very nice! Thank you for this wonderful archive. I wonder why I found it only now. Long live the BBS file archives!

  2. This is so awesome! 😀 I’d be cool if you could download an entire archive of this at once, though.

  3. But one thing that puzzles me is the “mtswslnkmcjklsdlsbdmMICROSOFT” string. There is an article about it here. It is definitely worth a read: http://www.os2museum.com/wp/mtswslnk/