home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Nibble Magazine
/
nib24b.dsk
/
NAVIGATOR.2.bas
< prev
next >
Wrap
BASIC Source File
|
2023-02-26
|
6KB
|
166 lines
10 REM ************************
20 REM * NAVIGATOR.2 *
30 REM * LISTING FORMATTER *
40 REM * BY LEE SWOBODA *
50 REM * COPYRIGHT (C) 1985 *
60 REM * BY MICROSPARC, INC *
70 REM * CONCORD, MA. 01742 *
80 REM ************************
90 REM
100 REM
110 D$ = CHR$(4)
120 HOME
130 EF = 1: ONERR GOTO 1210
140 PRINT D$"OPEN NAVIGATOR.TXT"
150 PRINT D$"READ NAVIGATOR.TXT"
160 INPUT NAME$,AUTH$,DT$,SELECT,COMMENTS,LMARGIN,RMARGIN,LPAGE,BMARGIN,D1,D2,SLOT
170 PRINT D$"CLOSE"
180 POKE 216,0
190 REM --------------
200 REM DEFAULT VALUES
210 REM --------------
220 SLOT$ = "PR#" + STR$(SLOT)
230 PAGE = 0: REM PAGE NUMBER
240 LNLGTH = RMARGIN -LMARGIN: REM LINE LENGTH
250 HEADER$(1) = NAME$
260 FOR I = 1 TO LNLGTH - LEN(NAME$) -9
270 HEADER$(1) = HEADER$(1) +" "
280 NEXT I
290 HEADER$(1) = HEADER$(1) +"PAGE "
300 HEADER$(2) = AUTH$
310 FOR I = 1 TO LNLGTH - LEN(AUTH$) -9
320 HEADER$(2) = HEADER$(2) +" "
330 NEXT I
340 HEADER$(2) = HEADER$(2) +DT$
350 FOR I = 1 TO LNLGTH
360 HEADER$(3) = HEADER$(3) +"-"
370 NEXT I
380 LPAGE = LPAGE -BMARGIN
390 DIM A$(40)
400 PRINT D$SLOT$: PRINT CHR$(9)"80N"
410 GOSUB 1470
420 EF = 2: ONERR GOTO 1210
430 PRINT D$"OPEN EXX,D"D1
440 PRINT D$"READ EXX"
450 REM ------------
460 REM BUILD STRING
470 REM ------------
480 B$ = ""
490 GET A$
500 IF A$ = CHR$(13) GOTO 530
510 B$ = B$ +A$: IF LEN(B$) = 248 THEN B$ = "<<< LISTED LINE TOO LONG FOR NAVIGATOR >>>": GOSUB 1650: GOTO 610
520 GOTO 490
530 B = VAL(B$)
540 IF B = 0 GOTO 490
550 A$ = STR$(B)
560 B = LEN(A$)
570 A$ = LEFT$(A$ +" ",6)
580 B$ = RIGHT$(B$, LEN(B$) -B -1)
590 IF LEFT$(B$,1) = " " THEN B$ = RIGHT$(B$, LEN(B$) -1): GOTO 590
600 B$ = A$ +B$
610 REM -------------
620 REM FORMAT STRING
630 REM -------------
640 J = 1: REM STRING SUBSCRIPT
650 L = 0: REM SUBSTRING LENGTH
660 K = LEN(B$)
670 IF MID$ (B$,7,3) = "REM" OR MID$ (B$,7,4) = "DATA" THEN RFLAG = 1
680 A$(1) = ""
690 B$ = B$ +" "
700 REM FORMAT LINES
710 QFLAG = 0
720 FOR I = 1 TO K
730 L = L +1
740 A$ = MID$ (B$,I,1)
750 IF A$ <" " THEN A$ = "^" + CHR$( ASC(A$) +224): REM CONTROL CHARACTERS
760 IF A$ = CHR$(34) THEN QFLAG = NOT QFLAG: REM STRINGS
770 IF QFLAG AND A$ = " " THEN A$ = CHR$(126): REM CHANGE SPACE TO TILDE
780 IF QFLAG OR RFLAG GOTO 910
790 IF MID$ (A$(J),7,2) = "IF" AND MID$ (B$,I,4) = "GOTO" THEN J = J +1:A$(J) = " ":L = 9: GOTO 860
800 IF MID$ (A$(J),7,2) = "IF" AND MID$ (B$,I,4) = "THEN" THEN J = J +1:A$(J) = " ":L = 9: GOTO 860
810 IF MID$ (B$,7,2) = "IF" AND MID$ (A$(J),5,1) < >":" AND MID$ (B$,I,4) = "GOTO" THEN J = J +1:A$(J) = " ":L = 9: GOTO 830
820 IF MID$ (B$,7,2) = "IF" AND MID$ (A$(J),5,1) < >":" AND MID$ (B$,I,4) = "THEN" THEN J = J +1:A$(J) = " ":L = 9: GOTO 830
830 IF A$ < >":" GOTO 860
840 IF MID$ (B$,I -3,4) = "MEM:" GOTO 860
850 J = J +1:A$(J) = " : ":A$ = "":L = 6: REM NEWLINE
860 IF I <7 GOTO 910
870 IF A$ = " " AND RIGHT$(A$(J),1) = " " GOTO 920
880 IF A$ = " " AND RIGHT$(A$(J),1) = "(" GOTO 920
890 IF A$ = " " AND MID$ (B$,I +1,1) = "(" GOTO 920
900 IF A$ = "," THEN A$ = ", "
910 A$(J) = A$(J) +A$
920 NEXT I
930 REM -----------
940 REM PRINT LINES
950 REM -----------
960 GOSUB 1540: IF LCOUNT +J >(LPAGE) THEN GOSUB 1410: REM NEW PAGE?
970 FOR I = 1 TO J
980 IF MID$ (A$(I),9,4) = "THEN" THEN TFLAG = 1
990 IF COMMENTS = 0 AND MID$ (A$(I),7,3) = "REM" GOTO 1170: REM SKIP REMARKS?
1000 IF MID$ (B$,7,3) = "REM" AND R1 = 0 THEN PRINT :R1 = 1:LCOUNT = LCOUNT +1: REM SKIP LINE BEFORE REMARK
1010 IF MID$ (B$,7,3) < >"REM" AND R1 = 1 THEN PRINT :R1 = 0:LCOUNT = LCOUNT +1: REM SKIP LINE AFTER REMARK(S)
1020 LCOUNT = LCOUNT +1
1030 IF MID$ (A$(I),7,3) = "FOR" THEN INDENT = INDENT +5:LNLGTH = LNLGTH -5: REM INDENT FOR...NEXT LOOPS
1040 REM PRINT THE LINE
1050 PRINT CHR$(1) SPC( LMARGIN);
1060 IF MID$ (A$(I),5,1) < >":" GOTO 1090
1070 IF TFLAG THEN PRINT " ";
1080 PRINT SPC( INDENT)A$(I): GOTO 1120
1090 PRINT LEFT$(A$(I),6);
1100 IF MID$ (A$(I),7,3) < >"REM" AND MID$ (A$(I),7,4) < >"DATA" THEN PRINT SPC( INDENT);
1110 PRINT MID$ (A$(I),7, LEN(A$(I)))
1120 IF MID$ (A$(I),7,4) < >"NEXT" GOTO 1170
1130 IF INDENT >4 THEN LNLGTH = LNLGTH +5:INDENT = INDENT -5: REM UNINDENT FOR...NEXT LOOP
1140 FOR Z = 7 TO 80
1150 IF MID$ (A$(I),Z,1) = "," THEN IF INDENT >4 THEN LNLGTH = LNLGTH +5:INDENT = INDENT -5
1160 NEXT Z
1170 NEXT I
1180 RFLAG = 0: REM CANCEL "REM" FLAG
1190 TFLAG = 0: REM CANCEL "THEN" FLAG
1200 GOTO 480
1210 REM ===
1220 REM END
1230 REM ===
1240 E = PEEK(222):EL = PEEK(218) +256 * PEEK(219): POKE 216,0
1250 IF EF = 2 AND E = 5 GOTO 1300
1260 HOME : VTAB 12: PRINT "ERROR #"E" IN LINE "EL"."
1270 PRINT : PRINT "PRESS <ESC> TO QUIT,": PRINT "OR ANY OTHER KEY TO TRY AGAIN."
1280 GET Z$: PRINT : IF Z$ = CHR$(27) THEN PRINT D$"CLOSE": END
1290 ON EF GOTO 130,420,1390
1300 FOR I = 1 TO LPAGE +BMARGIN -LCOUNT
1310 PRINT
1320 NEXT I
1330 IF SELECT = 3 THEN PRINT D$"RUN NAVIGATOR.3,D"D1
1340 PRINT D$"PR#0"
1350 PRINT D$"CLOSE"
1360 PRINT D$"DELETE EXX"
1370 PRINT D$"OPEN EXE": PRINT D$"CLOSE EXE": PRINT D$"DELETE EXE"
1380 PRINT D$"OPEN EX1": PRINT D$"CLOSE EX1": PRINT D$"DELETE EX1"
1390 POKE 216,0
1400 END
1410 REM ============
1420 REM PRINT HEADER
1430 REM ============
1440 FOR P = 1 TO LPAGE +BMARGIN -LCOUNT
1450 PRINT
1460 NEXT P
1470 PAGE = PAGE +1
1480 PRINT SPC( LMARGIN)HEADER$(1)PAGE
1490 PRINT SPC( LMARGIN)HEADER$(2)
1500 PRINT SPC( LMARGIN)HEADER$(3)
1510 PRINT
1520 LCOUNT = 4
1530 RETURN
1540 SI = LNLGTH -10:I = 1
1550 T$ = A$(I)
1560 IF LEN(T$) < = SI GOTO 1630
1570 IF LEFT$(T$,6) = " " GOTO 1590
1580 SI = SI -5 *( MID$ (T$,7,3) = "FOR") +5 *( MID$ (T$,7,4) = "NEXT"): IF SI >LNLGTH -10 THEN SI = LNLGTH -10
1590 K = J:L = SI -1
1600 AL$ = MID$ (A$(I),L,1): IF AL$ < >" " AND AL$ < >"$" AND AL$ < >"," AND AL$ < > CHR$(126) THEN L = L -1: GOTO 1600
1610 A$(K +1) = A$(K):K = K -1: IF K > = I GOTO 1610
1620 A$(I) = LEFT$(T$,L):A$(I +1) = " " + MID$ (T$,L +1):J = J +1
1630 I = I +1: IF I < = J GOTO 1550
1640 RETURN
1650 GET AA$: IF AA$ < > CHR$(13) GOTO 1650
1660 RETURN