home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Nibble Magazine
/
nib26b.dsk
/
TEXTFILE.EDITOR.bas
< prev
next >
Wrap
BASIC Source File
|
2023-02-26
|
5KB
|
68 lines
10 REM *************************
20 REM * TEXTFILE.EDITOR *
30 REM * BY KEN MANLY *
40 REM * COPYRIGHT (C) 1985 *
50 REM * BY MICROSPARC, INC *
60 REM * CONCORD, MA 01742 *
70 REM *************************
100 REM INITIALIZE
110 GOSUB 610:FU = 3:DR = 1: HOME : ONERR GOTO 190
120 GOTO 290
130 REM HIGHLIGHT AND UNHIGHLIGHT MENU SUBROUTINE
140 VT = PEEK(37) +1:HT = PEEK(TP): TEXT : VTAB INT((FU +1)/2): POKE TP,WD/2 -20 *(FU/2 < > INT(FU/2)): PRINT FU" "C$(FU): POKE 34,5: VTAB VT: POKE TP,HT: RETURN
150 REM MENU CHOICE OR QUIT
160 GOSUB 140: PRINT "WHICH FUNCTION (<ESC> ENDS) ";: & GET NUM,T: ON QT GOTO 700: IF NOT (QT +RT +SP +BS) THEN FU = T
170 PRINT FU +SP -BS: GOTO 290
180 REM ERROR HANDLER
190 CALL SI: ON PEEK(222) GOTO 210,210,210,220,230,240,240,250,260,270,240,210,240,210,210,210,260,210,210,210,210
200 PRINT CHR$(7);: POKE 216,0: GOTO 290
210 PRINT CHR$(7)"DOS ERROR NUMBER " PEEK(222): GOTO 290
220 PRINT CHR$(7)"DISKETTE IS WRITE-PROTECTED": GOTO 290
230 PRINT : PRINT DD$"CLOSE": GOSUB 140:FU = FU +1: GOTO 290
240 PRINT CHR$(7)"NO SUCH TEXTFILE": GOTO 290
250 PRINT CHR$(7)"DRIVE ERROR": GOTO 290
260 PRINT CHR$(7)"DISK FULL": GOTO 290
270 PRINT CHR$(7)"UNLOCK "FF$" FILE? Y" CHR$(8);: & GET ANY,Q$: PRINT Q$: ON (QT +SP +BS) GOTO 290: IF (RT) OR Q$ = "Y" THEN PRINT DD$"UNLOCK"FF$: PRINT FF$" UNLOCKED; <RETURN> TO SAVE"
280 REM CONTROL CENTER: UPDATE FUNCTION USING FLAGS, HIGHLIGHT MENU ITEM, CALL FUNCTION SUBROUTINE
290 GOSUB 140:FU = FU +SP -BS:FU = FU +6 *(FU <1) -6 *(FU >6): INVERSE : GOSUB 140: NORMAL : HTAB WD/2 -14: PRINT "HIT <RETURN> FOR OPTION "FU; CHR$(8);
300 & GET NUM,T: PRINT (T *(T >0)) +(FU *(T = 0));: POKE TP,0: ON (SP) OR (BS) GOTO 290: ON (RT) GOTO 310: ON (QT) GOTO 160: GOSUB 140:FU = T +(FU +1) *(T <1):FU = FU -6 *(FU >6): GOTO 290
310 CALL EL: ON FU GOSUB 330,380,410,480,510,540: GOTO 290
320 REM READ FILE
330 PRINT "DRIVE? "DR; CHR$(8);: & GET NUM,T: PRINT (T >0) *T +(T = 0) *DR: ON (RT) GOTO 340: ON (QT +SP +BS) GOTO 360: ON (T <0 OR T >2) GOTO 330:DR = T
340 PRINT : PRINT DD$CT$",D"DR
350 PRINT "FILENAME? ";: & INPUT ANY,FF$: ON (QT +RT +SP +BS) GOTO 360: PRINT DD$"OPEN"FF$",D"DR: PRINT DD$"READ"FF$: FOR I = 1 TO MX: & INPUT EXT,A$(I):LL = I: NEXT I: PRINT : PRINT DD$"CLOSE": GOSUB 140:FU = FU +1
360 RETURN
370 REM VIEW TEXT
380 ON ( NOT LL) GOTO 390: FOR I = 1 TO LL: INVERSE : PRINT RIGHT$(" " + STR$(I),2);: NORMAL : PRINT " "A$(I): NEXT
390 PRINT : PRINT : RETURN
400 REM ADD LINE
410 ON LL = MX GOTO 460: PRINT "AFTER WHICH LINE? "LL;: POKE TP,18: & INPUT NUM,II: ON (QT +SP +BS) GOTO 450: VTAB PEEK(37): IF RT THEN II = LL
420 II = II +1: CALL EL: PRINT "LINE NUMBER "II: PRINT : & INPUT ANY,TT$: IF (QT +SP +BS) THEN 450
430 IF (II < = LL) THEN FOR I = LL TO II STEP -1:A$(I +1) = A$(I): NEXT
440 A$(II) = TT$:LL = LL +1: PRINT : GOTO 420
450 RETURN
460 FLASH : PRINT "FULL" CHR$(7): NORMAL : FOR I = 1 TO 1000: NEXT : GOSUB 140:SP = 0:BS = 0:FU = 2: RETURN
470 REM DELETE LINE
480 PRINT "WHICH LINE? ";: & INPUT NUM,II: ON (QT +RT +SP +BS) OR (II >LL) OR (LL = 0) GOTO 490: FOR I = II TO LL -1:A$(I) = A$(I +1): NEXT :LL = LL -1: VTAB PEEK(37): CALL EL: PRINT "DONE"
490 RETURN
500 REM EDIT LINE
510 PRINT "WHICH LINE? ";: & INPUT NUM,II: ON (QT +RT +SP +BS) GOTO 520: HOME : VTAB 12: PRINT A$(II): VTAB 20: PRINT "USE NORMAL KEYBOARD EDITING": VTAB 12: & INPUT EXT,A$(II)
520 HOME : RETURN
530 REM WRITE FILE
540 PRINT "DRIVE? "DR; CHR$(8);: & GET NUM,T: PRINT (T >0) *T +(T = 0) *DR: ON (RT) GOTO 550: ON (QT +SP +BS) GOTO 590: ON (T <0 OR T >2) GOTO 540:DR = T
550 PRINT "FILENAME? "FF$;: POKE TP,10: & INPUT ANY,TT$: ON (QT +SP +BS) GOTO 590: IF NOT RT THEN FF$ = TT$
560 PRINT DD$"OPEN"FF$",D"DR: PRINT DD$"CLOSE"FF$: PRINT DD$"DELETE"FF$: PRINT DD$"OPEN"FF$: PRINT DD$"WRITE"FF$
570 FOR I = 1 TO LL: PRINT A$(I): NEXT : PRINT DD$"CLOSE"
580 PRINT "LOCK FILE? N" CHR$(8);: & GET ANY,Q$: PRINT Q$: ON (QT +RT +SP +BS) GOTO 590: IF Q$ = "Y" THEN PRINT DD$"LOCK"FF$
590 RETURN
600 REM ACTIVATE INPUT ROUTINES
610 PRINT CHR$(4)"BRUNPROSIR"
620 REM DEFINE VARIABLES AND MAKE MENU
630 MX = INT(( FRE(0) -2000)/250): DIM A$(MX): & DEF QT,RT,SP,BS:DD$ = CHR$(4):EL = -868:SI = 54915:WD = 40:TP = 36: IF PEEK(64435) = 6 AND PEEK(49183) >127 THEN WD = 80:TP = 1403
640 CT$ = "CATALOG": IF ( PEEK(48640) = 76 AND PEEK(48643) = 76 AND PEEK(49183) <128) THEN CT$ = "CAT"
650 TEXT : HOME : VTAB 10: PRINT TAB( WD/2 -14)"TEXTFILE.EDITOR BY KEN MANLY": PRINT : PRINT TAB( WD/2 -19)"** COPYRIGHT 1985 BY MICROSPARC, INC **": PRINT : PRINT TAB( WD/2 -13)"PRESS <RETURN> TO CONTINUE": GET Z$: PRINT
660 TEXT : HOME : FOR FU = 1 TO 6: READ C$(FU): GOSUB 140: NEXT
670 VTAB 4: PRINT TAB( WD/2 -14)"<SP>,<BS>-->CHANGE FUNCTION": PRINT TAB( WD/2 -8)"<ESC>-->QUIT": POKE 34,5: RETURN
680 DATA READ FILE ,VIEW TEXT ,ADD LINE ,DEL LINE ,EDIT LINE ,WRITE FILE
690 REM END
700 TEXT : HOME : PRINT CHR$(12); CHR$(21): PRINT "GOODBYE": END