home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Nibble Magazine
/
nib19a.dsk
/
APRIL.1984
/
SOURCE.EDITOR.bas
< prev
next >
Wrap
BASIC Source File
|
2023-02-26
|
6KB
|
166 lines
10 REM **********************
20 REM * SOURCE.EDITOR *
30 REM * BY JOHN WHITNEY *
40 REM * COPYRIGHT (C) 1984 *
50 REM * BY MICROSPARC, INC *
60 REM * LINCOLN, MA. 01773 *
70 REM **********************
80 REM ******************************
90 REM * THIS PROGRAM WILL CREATE *
100 REM * AND EDIT ASSEMBLER SOURCE *
110 REM * PROGRAMS TO BE ASSEMBLED *
120 REM * BY THE ASSEMBLER PROGRAM *
130 REM * *
140 REM ******************************
150 REM *** SET UP ***
160 D$ = CHR$(4)
170 DIM A$(250),A(250)
180 HOME : VTAB 22: PRINT "** COPYRIGHT 1984 BY MICROSPARC, INC. **"
190 VTAB 2: INVERSE : PRINT "SOURCE EDITOR": NORMAL
200 GOSUB 1440: ONERR GOTO 1600
210 VTAB 6: CALL -958: INPUT "ENTER FILE NAME: ";PR$: IF LEN(PR$) = 0 OR LEN(PR$) >15 OR VAL(PR$) >0 THEN 210
220 VTAB 8: CALL -958: PRINT D$"OPEN"PR$: PRINT D$"CLOSE"
230 VTAB 8: INPUT "IS THIS A NEW FILE? (Y/N): ";NP$
240 IF NP$ = "N" THEN GOSUB 1090: GOTO 280
250 IF NP$ = "Y" OR NP$ = "" THEN PRINT : GOTO 300
260 VTAB 8: CALL -958: GOTO 230
270 REM *** EDIT PROGRAM ***
280 PRINT : PRINT "EDIT"
290 GOSUB 870
300 IF L$ = "" THEN L$ = "I 99999": GOSUB 390: GOTO 280
310 IF VAL(L$) < >0 THEN GOSUB 510: GOTO 280
320 IF LEFT$(L$,2) = "D " THEN GOSUB 590: GOTO 280
330 IF LEFT$(L$,1) = "L" THEN GOSUB 710: GOTO 280
340 IF LEFT$(L$,1) = "P" THEN PRINT D$"PR#1": GOSUB 710: PRINT D$"PR#0": GOTO 280
350 IF LEFT$(L$,1) = "?" THEN GOSUB 1350: GOTO 280
360 IF LEFT$(L$,2) = "I " THEN GOSUB 390: GOTO 280
370 IF LEFT$(L$,4) = "SAVE" THEN 1200
380 PRINT "INVALID COMMAND": GOTO 280
390 REM *** INPUT ***
400 PRINT "INPUT"
410 N = 0:NL = 1
420 IF A(N) < >0 AND NL < VAL( MID$ (L$,3)) +1 THEN N = A(N):NL = NL +1: GOTO 420
430 PRINT NL":"
440 GOSUB 870
450 IF L$ = "" THEN RETURN
460 J = 1
470 IF A$(J) < >"" THEN J = J +1: GOTO 470
480 A$(J) = L$
490 A(J) = A(N):A(N) = J:N = J:NL = NL +1
500 GOTO 430
510 REM *** RE ENTER LINE ***
520 N = 0
530 FOR J = 1 TO VAL(L$)
540 IF A(N) = 0 THEN PRINT "LINE NOT FOUND": RETURN
550 N = A(N)
560 NEXT
570 PRINT VAL(L$);":": PRINT A$(N);:L$ = A$(N) + LEFT$(" ",40 - LEN(A$(N))): HTAB 1: GOSUB 900: IF L$ = "" THEN RETURN : REM 40 SPACES BETWEEN QUOTES
580 A$(N) = L$: RETURN
590 REM *** DELETE LINE ***
600 LN = VAL( MID$ (L$,2)) -1
610 IF LN <0 THEN PRINT "LINE NOT FOUND": RETURN
620 N = 0
630 IF LN = 0 THEN 680
640 FOR J = 1 TO LN
650 IF A(N) = 0 THEN PRINT "LINE NOT FOUND": RETURN
660 N = A(N)
670 NEXT
680 A$(A(N)) = ""
690 A(N) = A(A(N))
700 RETURN
710 REM *** LIST ***
720 IF LEN(L$) <3 THEN LS = 0:LE = 0: GOTO 790
730 LS = VAL( MID$ (L$,3))
740 IF LEN(L$) <4 THEN 780
750 FOR K = 4 TO LEN(L$)
760 IF MID$ (L$,K,1) = "," OR MID$ (L$,K,1) = " " THEN LE = VAL( MID$ (L$,K +1)): GOTO 790
770 NEXT
780 LE = LS
790 IF LE = 0 THEN LE = 99999
800 N = 0
810 FOR J = 1 TO LE
820 N = A(N)
830 IF N = 0 THEN 860
840 IF J > = LS THEN PRINT J;":";A$(N)
850 NEXT
860 RETURN
870 REM *** GET LINE ***
880 L$ = " "
890 REM L$= 40 SPACES
900 CC = 1
910 IF CC <1 THEN CC = 1
920 IF CC >39 THEN CC = 39
930 HTAB CC: GET KB$
940 IF ASC(KB$) = 8 THEN CC = CC -1: GOTO 910
950 IF ASC(KB$) = 21 THEN CC = CC +1: GOTO 920
960 IF ASC(KB$) = 13 THEN 1040
970 IF ASC(KB$) = 24 THEN PRINT CHR$(92): GOTO 880
980 IF ASC(KB$) = 27 THEN CC = 10: GOTO 930
990 ON ASC(KB$) <32 GOTO 930: PRINT KB$;
1000 IF CC = 1 THEN L$ = KB$ + MID$ (L$,2):CC = CC +1: GOTO 930
1010 IF CC = 39 THEN L$ = LEFT$(L$,38): HTAB CC: PRINT " ";: GOTO 930
1020 L$ = LEFT$(L$,CC -1) +KB$ + MID$ (L$,CC +1)
1030 CC = CC +1: GOTO 930
1040 IF CC = 1 THEN L$ = "": GOTO 1060
1050 L$ = LEFT$(L$,CC -1)
1060 HTAB 1: PRINT L$; SPC( 40 -C)
1070 PRINT
1080 RETURN
1090 REM *** READ FILE ***
1100 A(0) = 1: ONERR GOTO 1600
1110 PRINT D$"OPEN "PR$
1120 PRINT D$"READ "PR$
1130 N = N +1
1140 INPUT A$(N)
1150 IF MID$ (A$(N),10,3) = "EOF" THEN A$(N) = "":N = N -1:A(N) = 0: GOTO 1180
1160 A(N) = N +1
1170 GOTO 1130
1180 PRINT D$"CLOSE "PR$: POKE 216,0
1190 RETURN
1200 REM *** SAVE ***
1210 ONERR GOTO 1600
1220 PRINT : PRINT D$"OPEN "PR$: PRINT D$"CLOSE": PRINT D$"DELETE "PR$
1230 PRINT D$"OPEN "PR$
1240 PRINT D$"WRITE "PR$
1250 N = 0
1260 PRINT CHR$(34)A$(A(N)) CHR$(34)
1270 LN = N
1280 N = A(N)
1290 IF A(N) < >0 THEN 1260
1300 IF MID$ (A$(LN),10,3) < >"EOF" THEN PRINT CHR$(34)" EOF" CHR$(34)
1310 PRINT D$"CLOSE "PR$
1320 INPUT "DO YOU WISH TO ASSEMBLE YOUR FILE? (Y/N)";K$: IF K$ = "Y" THEN PRINT D$"RUN BASIC.ASSEMBLER"
1330 HOME : POKE 216,0: END
1340 REM HELP SCREEN
1350 HOME : INVERSE : PRINT "COMMANDS: ": NORMAL
1360 PRINT "L LIST ENTIRE PROGRAM"
1370 PRINT : PRINT "L N LIST LINE N"
1380 PRINT : PRINT "L N,M LIST LINES N THROUGH M"
1390 PRINT : PRINT "D N DELETE LINE N"
1400 PRINT : PRINT "I N INPUT LINES AFTER N"
1410 PRINT : PRINT "P (N(,M)) PRINT LISTING"
1420 PRINT : PRINT "SAVE SAVE THE PROGRAM TO DISK"
1430 PRINT : PRINT "N EDIT LINE N"
1434 PRINT : PRINT "<ESC> TAB (ONLY IN EDIT OR INPUT)"
1436 PRINT : PRINT "? THIS HELP SCREEN": RETURN
1440 DIM PN(15)
1450 PN(1) = 66:PN(2) = 89:PN(3) = 32
1460 PN(4) = 74:PN(5) = 79:PN(6) = 72
1470 PN(7) = 78:PN(8) = 32:PN(9) = 87
1480 PN(10) = 72:PN(11) = 73:PN(12) = 84
1490 PN(13) = 78:PN(14) = 69:PN(15) = 89
1500 FOR VN = 1 TO 15
1510 VTAB 4
1520 FOR VO = VN TO 1 STEP -1
1530 PRINT CHR$(PN(16 -VO));
1540 NEXT VO
1550 PRINT
1560 NEXT VN
1570 PRINT
1580 RETURN
1590 REM ERROR TRAP FOR SAVE
1600 POKE 216,0: PRINT : PRINT D$"CLOSE"
1610 IF PEEK(222) = 5 THEN PRINT D$"DELETE"PR$: PRINT CHR$(7)"FILE NOT ON THIS DISK": PRINT "PRESS ANY KEY =>";: GET A$: PRINT : RUN
1620 IF PEEK(222) = 16 THEN PRINT CHR$(7)"INVALID FILE NAME. PRESS ANY KEY =>";: GET A$: PRINT : RUN
1630 IF PEEK(222) = 6 THEN PRINT "PUT IN DISK WITH BASIC.ASSEMBLER": PRINT "AND PRESS ANY KEY +>";: GET A$: PRINT : GOTO 1310
1700 PRINT CHR$(7)"DISK ERROR #"; PEEK(222);" IN LINE "; PEEK(218) + PEEK(219) *256