100  D$ =  CHR$ (4)
105  W = 1000
110  DIM W$(W)
115  L = 0
130  F$ = ""
140  P$ = "N/A"
150  R$ =  CHR$ (13)
155  EO$ =  CHR$ (26)
160  LS = 23
170  FC = 0
175  IL = 0 
180  R = 0
205  TEXT : HOME 
210  PRINT "---------------------------------------"
215  PRINT "      TEXT FILE EDITOR / VIEWER"
220  PRINT "         BY MICHAEL O'MALLEY"
225  PRINT "---------------------------------------"
230  PRINT " DIR : "P$;
235  PRINT ", FILE : "F$;
237  IF F$ <  > "" AND FC = 0 THEN  PRINT " (NOCHG)"
238  IF F$ <  > "" AND FC = 1 THEN  PRINT " (CHG)"
239  IF F$ = "" THEN  PRINT 
240  PRINT "   "L" LINES LOADED (CAPACITY = "W")"
243  PRINT "---------------------------------------";
245  PRINT : PRINT "  F. CHANGE CURRENT FILE"
250  PRINT : PRINT "  D. DISPLAY FILE TO SCREEN"
255  PRINT : PRINT " DE. DELETE LINE(S)"
260  PRINT : PRINT " IN. INSERT LINE(S)"
265  PRINT : PRINT " CD. CHANGE DIRECTORY (PRO-DOS ONLY)"
270  PRINT : PRINT "  C. CATALOG DISK"
272  PRINT : PRINT "  S. SAVE FILE TO DISK"
275  PRINT : PRINT "  Q. QUIT PROGRAM"
285  PRINT : PRINT " PLEASE ENTER YOUR CHOICE : ";
290  A$ = "" : INPUT A$
295  IF A$ = "F" THEN  GOSUB 500
300  IF A$ = "D" THEN  GOSUB 700
305  IF A$ = "DE" THEN  GOSUB 900 
310  IF A$ = "IN" THEN  GOSUB 1100
315  IF A$ = "CD" THEN  GOSUB 1400
320  IF A$ = "C" THEN  GOSUB 1500 
322  IF A$ = "S" THEN  GOSUB 9400 
325  IF A$ = "Q" THEN  GOSUB 9900
330  IF A$ <  > "F" AND A$ <  > "D" AND A$ <  > "DE" AND A$ <  > "IN" AND A$ <  > "CD" AND A$ <  > "C" AND A$ <  > "S" AND A$ <  > "Q" THEN  PRINT : PRINT "*ERROR: INVALID INPUT !!" : GOTO 285
499  GOTO 200

510  GOSUB 9500
515  PRINT : PRINT 
520  INPUT "ENTER FILE : "; F$
525  ONERR  GOTO 580
527  L = 0
529  PRINT 
530  PRINT D$; "OPEN "; F$
532  PRINT "OPEN "; F$
535  PRINT D$; "READ "; F$
536  PRINT "READ "; F$
537  PRINT "READING FILE ... "
540  FOR I = 1 TO W
545  INPUT W$(I)
555  L = L + 1
570  NEXT I
580  PRINT 
585  PRINT D$; "CLOSE "; F$
590  PRINT L" LINES LOADED !"
595  GOSUB 9700
597  FC = 0
599  GOTO 200

710  TEXT : HOME 
715  IF F$ = "" THEN  PRINT : PRINT " << NO FILE HAS BEEN SELECTED >>" : GOTO 790
720  IF L = 0 THEN  PRINT : PRINT " << FILE IS EMPTY >>" : GOTO 790
725  C = 0
730  FOR I = 1 TO L
735  PRINT W$(I)
740  C = C + 1
750  IF C = LS THEN C = 0 : GOSUB 9700
760  NEXT I
790  GOSUB 9700
799  RETURN 

915  PRINT : PRINT 
920  PRINT " DELETE FROM LINE (1-"; L; ", -1=QUIT) : ";
922  INPUT SL
923  IF SL =  - 1 THEN  GOTO 990
925  IF SL < 0 THEN  PRINT : PRINT "*ERROR: CANNOT DELETE PRIOR TO START !" : GOTO 915
930  IF SL > L THEN  PRINT : PRINT "*ERROR: CANNOT DELETE AFTER END !" : GOTO 915
940  PRINT : PRINT " DELETE TO LINE ("; SL; "-"; L; ", -1=QUIT) : ";
942  INPUT EL
943  IF EL =  - 1 THEN  GOTO 990
945  IF EL < SL THEN  PRINT : PRINT "*ERROR: CANNOT DELETE PRIOR TO START LINE !" : GOTO 940
950  IF EL > L THEN  PRINT : PRINT "*ERROR: CANNOT DELETE AFTER END !" : GOTO 940
960  FOR IL = EL TO SL STEP  - 1
970  GOSUB 1000
980  NEXT IL
985  FC = 1
990  GOSUB 9700
999  RETURN 

1010  ONERR  GOTO 1090
1035  IF L = IL THEN  GOTO 1090
1040  IF IL > L THEN  GOTO 1099
1062   PRINT "**DEBUG: L = "; L; ", IL = "; IL
1065  FOR R = IL TO L
1070  W$(R) = W$(R + 1)
1080  NEXT R
1090  L = L - 1
1099  RETURN 

1110  TEXT : HOME 
1112  IF F$ = "" THEN  PRINT : PRINT " << NO FILE HAS BEEN SELECTED >>" : GOTO 1290
1114  IF L = 0 THEN  GOTO 1150
1116  IF L = W THEN  PRINT : PRINT "*ERROR: ARRAY SIZE ("; W; ") REACHED !" : GOTO 1290
1118  PRINT " INSERT LINES AFTER WHICH LINE (0-"; L; ") ";
1120  INPUT IL
1135  IF IL < 0 THEN  PRINT : PRINT "*ERROR: CANNOT INSERT LINE PRIOR TO START !" : GOTO 1115
1140  IF IL > L THEN IL = L : PRINT " INSERTING LINES AT END-OF-FILE"
1150  PRINT 
1152  PRINT " *** ENTER LINES NOW *** "
1154  PRINT " (DO NOT ENTER ANY COMMAS !)"
1156  PRINT "   (ENTER --Q TO QUIT)"
1160  PRINT : PRINT (IL + 1); ". ";
1165  INPUT NL$
1170  IF NL$ = "--Q" THEN  GOTO 1290
1185  GOSUB 1300
1190  W$(IL) = NL$
1195  FC = 1
1200  GOTO 1160
1290  GOSUB 9700
1299  RETURN 

1310  ONERR  GOTO 1390
1315  IF L = W THEN  PRINT : PRINT "*ERROR: ARRAY SIZE ("; W; ") EXCEEDED !" : GOTO 1399
1320  L = L + 1
1325  IL = IL + 1
1335  IF L = IL THEN  GOTO 1390
1350  SP = IL
1360  IF IL <  = 1 THEN SP = 2
1362   PRINT "**DEBUG: L = "; L; ", IL = "; IL
1365  FOR R = L TO SP STEP  - 1
1370  W$(R) = W$(R - 1)
1380  NEXT R
1390  W$(IL) = ""
1399  RETURN 
1410  TEXT : HOME 
1415  ONERR  GOTO 1470
1425  PRINT : PRINT 
1430  PRINT " WARNING: DIRECTORIES ARE PRO-DOS ONLY !"
1435  PRINT " ENTER NOTHING IF YOU ARE NOT SURE !!"
1440  PRINT : PRINT 
1445  INPUT "INPUT PREFIX "; P$
1450  IF P$ = "" THEN  GOTO 1470
1460  PRINT D$; "PREFIX "; P$
1470  GOSUB 9700
1499  RETURN 

1510  TEXT : HOME 
1520  PRINT D$; "CATALOG"
1530  GOSUB 9700 
1599  RETURN 

9410  IF FC = 0 THEN  PRINT : PRINT " << FILE HAS NOT CHANGED >>" : GOTO 9490
9415  ONERR  GOTO 9490
9420  PRINT "SAVING "; F$; " ... "
9425  PRINT D$; "OPEN "; F$
9430  PRINT D$; "WRITE "; F$
9450  FOR I = 1 TO L
9460  PRINT W$(I)
9470  NEXT I
9475  PRINT D$; "CLOSE "; F$
9480  PRINT "CLOSE "; F$
9485  PRINT L" LINES SAVED !"
9490  GOSUB 9700
9495  FC = 0
9499  RETURN 

9510  IF FC = 0 THEN  GOTO 9599
9520  PRINT : PRINT 
9525  INPUT "SAVE CHANGED FILE TO DISK (Y/N) "; AN$
9530  IF AN$ = "Y" THEN  GOSUB 9400
9599  RETURN 

9710  PRINT : PRINT 
9715  PRINT " << HIT ANY KEY TO CONTINUE >> ";
9720  GET H1$
9730  PRINT 
9790   HOME
9799  RETURN 

9810  PRINT : PRINT "DOS ERROR CODE = " PEEK (222)
9825  PRINT "CLOSE "; F$
9830  PRINT D$; "CLOSE "; F$
9899  RETURN 

9905  TEXT : HOME 
9910  GOSUB 9500
9970  PRINT : PRINT 
9975  PRINT "THANKS FOR USING TEXT EDITOR / VIEWER"
9980  PRINT : PRINT 
9985  PRINT "DON'T FORGET : CONTACT MIKE O'MALLEY"
9990  PRINT "               FOR PROGRAM UPDATES"
9995  PRINT : PRINT 
9999  END 
