20 N%=0:FILENAME$=""
30 PRINT CHR$(26);"*REVISED 20 FEB 1982*"
40 A=52
60 NT%=500
95 DIM D$(500)
100 REM 27 SEPT 81 ***TEXT EDITOR***********
110 NC%=21:DIM C$(21):CS%=0
120 FOR I%=1 TO NC%:READ C$(I%):NEXT I%
160 DATA ADD,DELETE,LIST,LOAD
170 DATA QUIT,SAVE,DITTO,NEXT,SCRATCH
171 DATA INSERT,FIND,CHANGE,SUBLIST,TOP
172 DATA LINE,PRINT,BACK
173 DATA KILL,RENAME,LOAD UNDOC,GLOBAL CHANGE
180 PRINT:PRINT"COMMANDS ARE:"
190 I1=1:FOR I%=1 TO NC%:PRINT C$(I%);
191 IF I%=3*INT(I%/3)THEN 195
192 IF I%=I1 THEN PRINT TAB(17)::I1=I1+3:GOTO 196
193 PRINT TAB(34);:GOTO 196
195 PRINT
196 NEXT I%
200 PRINT:PRINT:GOSUB 8950
201 LINE INPUT"COMMAND: ";A$:GOSUB 8965
203 IF LEN(A$)<1 THEN 180
205 X=0
207 FOR I%=1 TO NC%
209 IF LEN(A$)>LEN(C$(I%))THEN 230
211 IF A$<>LEFT$(C$(I%),LEN(A$))THEN 230
212 IF LEN(A$)=LEN(C$(I%))THEN 250
213 IF X>0 THEN 180
215 X=I%
230 NEXT I%:I%=X
240 IF I%=0 THEN 180
250 ON I% GOTO 500,1000,1500,2000,2500
260 I%=I%-5:ON I% GOTO 3000,3500,4000,4500,5000
270 I%=I%-5:ON I% GOTO 5500,6000,6500,7000,7500
280 I%=I%-5:ON I% GOTO 8000,4750,8750,9000,10000
290 I%=I%-5:ON I% GOTO 11000
400 GOTO 180
500 PRINT"USE '/' TO TERMINATE":REM ADD DATA 
520 IF N%<500 THEN 530
522 PRINT"DATA DUMP REQ'D":GOTO 200
530 LINE INPUT D$(N%+1)
540 IF D$(N%+1)="/" THEN 7000
550 N%=N%+1:GOTO 520
1000 IF CS%>=1 THEN 1030:REM *DELETE*
1012 PRINT"NO LINE PRESENT!":GOTO 200
1020 IF CS%>N% THEN 1012
1030 GOSUB 8925
1050 PRINT:PRINT"DELETE IT";
1060 INPUT A$:GOSUB 8965:Q$="YN":GOSUB 8910
1080 ON Q% GOTO 1100,200,1030
1100 IF CS%=N% THEN 1200
1110 FOR I%=CS% TO (N%-1)
1120 D$(I%)=D$(I%+1)
1130 NEXT I%:GOSUB 8960
1140 N%=N%-1
1150 GOTO 1020
1200 N%=N%-1:CS%=CS%-1:PRINT" *DONE*"
1220 GOSUB 8925:GOTO 200
1500 FOR I%=1 TO 20:PRINT:NEXT I%:REM *LIST*
1520 CL=0
1530 CL=CL+1:PRINT D$(CL)
1550 IF CL=10*INT(CL/10) THEN 1600
1560 IF CL<N% THEN 1530
1570 GOTO 1645
1600 PRINT:PRINT"*READY TO CONTINUE*"
1610 LINE INPUT A$:GOSUB 8965:PRINT:Q$="YN":GOSUB 8910
1630 ON Q% GOTO 1560,1650,1560
1645 IF CS%>0 THEN 1650
1646 GOTO 7000
1650 GOSUB 8925:GOTO 200
2000 REM *LOAD DATA *
2002 RESET:PRINT:PRINT"drive a:":FILES "A:*.*":PRINT
2004 PRINT:PRINT"drive b:":FILES "B:*.*":PRINT:PRINT
2010 INPUT"DRIVE (A or B)";DR$
2015 A$=DR$:GOSUB 8965:DR$=A$
2020 IF DR$<>"A" AND DR$<>"B" THEN 2010
2025 RESET
2030 LINE INPUT"FILENAME (NAME.TYP)";FILENAME$
2040 A$=FILENAME$:GOSUB 8965:FILENAME$=DR$+":"+A$
2060 OPEN "I",#1,FILENAME$
2070 IF EOF(1)THEN 2300
2080 IF N%>=500 THEN 2350
2090 N%=N%+1:LINE INPUT #1,D$(N%)
2100 GOTO 2070
2300 RESET
2310 GOSUB 8955:GOTO 7000
2350 PRINT:PRINT"**CANNOT LOAD ENTIRE FILE**"
2360 GOTO 2300
2500 INPUT"REALLY WANT TO QUIT NOW";A$:GOSUB 8965
2520 Q$="YN":GOSUB 8910
2530 ON Q% GOTO 2550,200,2500
2550 PRINT"*REMOUNT SYSTEM DISK AND HIT return*"
2560 LINE INPUT A$:SYSTEM
3000 REM ***SAVE****
3010 PRINT:PRINT"READY TO SAVE DATA ON DISK"
3020 PRINT:PRINT"CURRENT FILENAME IS ";FILENAME$
3030 INPUT"CHANGE THE FILENAME";A$
3040 A$=LEFT$(A$,1):GOSUB 8965
3050 Q$="YN":GOSUB 8910
3060 ON Q% GOTO 3070,3120,3020
3070 INPUT"DRIVE (A or B)";A$:A$=LEFT$(A$,1):GOSUB 8965
3080 DR$=A$:IF DR$<>"A" AND DR$<>"B" THEN 3070
3085 RESET:FILES (DR$+":*.*"):PRINT
3090 LINE INPUT"FILENAME (NAME.TYP)";A$:GOSUB 8965
3100 FILENAME$=DR$+":"+A$
3120 RESET:OPEN "O",#1,FILENAME$
3130 FOR I%=1 TO N%
3140 PRINT #1,D$(I%)
3150 NEXT I%
3160 RESET
3170 GOSUB 8955:GOTO 7000
3500 GOSUB 8925:REM *DITTO*
3520 PRINT"*READY TO DITTO BELOW THIS LINE*"
3570 Q$="!C&":CT=CS%
3580 PRINT:PRINT"LINES TO BE DITTO'D:"
3600 INPUT"FIRST #";S0%
3610 INPUT"LAST #";S1%
3640 IF S0%<1 OR S1%>N% THEN 3800
3644 IF CS%=N% THEN 3850
3650 IF S1%-S0%+N%+1>500 THEN 3800
3655 IF S0%<=CS% AND S1%>=CS% THEN 3820
3656 L1=CS%:L=S0%
3660 FOR K=0 TO S1%-S0%
3670 A$=D$(L):GOSUB 5101
3684 L=L+1:IF S0%>CT THEN L=L+1
3688 NEXT K
3690 PRINT TAB(5);"**DONE**"
3710 GOSUB 8925:Q$=""
3720 GOTO 200
3800 PRINT"*IMPOSSI%BLE!*"
3810 GOTO 3710
3820 PRINT"*MAY NOT OVERLAP CURRENT LINE!*"
3840 GOTO 3710
3850 FOR K=0 TO S1%-S0%:D$(N%+1)=D$(S0%+K)
3870 N%=N%+1:NEXT K
3890 GOTO 3690
4000 IF CS%<N% THEN 4100:REM *NEXT *
4020 GOTO 7000
4100 CS%=CS%+1:GOSUB 8925:GOTO 200
4500 INPUT"ERASE ALL DATA";A$:GOSUB 8965
4530 Q$="YN":GOSUB 8910:ON Q% GOTO 4560,200,4500
4560 FOR I%=1 TO N%:D$(I%)="":NEXT I%:N%=0
4570 PRINT"  **DONE**":GOSUB 8955:GOTO 7000
4750 CS%=CS%-1:IF CS%<=0 THEN 7000:REM *BACK*
4770 GOSUB 8925:GOTO 200
5000 IF CS%=N% THEN 500:REM *INSERT*
5020 GOSUB 8925:PRINT"USE '/' TO TERMINATE"
5101 IF N%+1>500 THEN 5220
5105 IF Q$="!C&" THEN 5120
5110 LINE INPUT A$:IF A$="/" THEN 5230
5120 N%=N%+1
5140 FOR I%=(N%+1) TO (CS%+2) STEP -1
5150 D$(I%)=D$(I%-1):NEXT I%:GOSUB 8960
5170 CS%=CS%+1:D$(CS%)=A$
5190 IF Q$="!C&" THEN  RETURN
5210 GOTO 5101
5220 PRINT"DATA DUMP REQ'D"
5230 GOSUB 8925:GOTO 200
5500 REM *FIND STRING*
5510 C%=0:GOSUB 5520:CS%=X1%:GOSUB 8925:GOTO 200
5520 LINE INPUT"STRING TO BE FOUND: ",S0$
5530 X%=CS%:X1%=0:'subroutine entry point
5540 WHILE X%<N%
5550 X%=X%+1
5560 S0%=INSTR(D$(X%),S0$)
5570 IF S0%<1 THEN 5590
5580 X1%=X%:X%=N%
5590 WEND
5600 IF X1%>0 THEN PRINT D$(X1%):GOTO 5620
5610 IF C%=0 THEN PRINT"*NO FIND* '"S0$"'"
5620 RETURN
6000 GOSUB 8925:REM *CHANGE CURRENT*
6006 IF CS%=0 THEN 7000
6010 PRINT"STRING TO BE CHANGED"
6020 LINE INPUT A$:S0$=A$
6030 L0=LEN(S0$):LD=LEN(D$(CS%))
6040 IF L0>LD THEN 6010
6050 FOR I%=1 TO LD
6060 IF S0$=MID$(D$(CS%),I%,L0) THEN 6200
6070 IF I%+L0-1>=LD THEN 6090
6080 NEXT I%
6090 PRINT"NO FIND '";S0$;"'"
6100 PRINT"IN STRING:"
6110 GOTO 200
6200 IF I%>1 THEN 6220
6210 S1$="":GOTO 6230
6220 S1$=LEFT$(D$(CS%),(I%-1))
6230 IF LD-I%-L0+1>0 THEN 6250
6240 S2$="":GOTO 6260
6250 S2$=RIGHT$(D$(CS%),(LD-I%-L0+1))
6260 PRINT"WHAT DO YOU WANT"
6261 PRINT"'";S0$;"'":PRINT" TO BECOME"
6263 LINE INPUT A$:S0$=A$:D$(CS%)=S1$+S0$
6270 D$(CS%)=D$(CS%)+S2$
6280 GOSUB 8925:GOTO 200
6500 PRINT:INPUT"# LINES TO LIST";NZ%
6520 IF NZ%<1 THEN 6500
6530 INPUT"PRINT  LINE #'S WITH EACH LINE";A$:GOSUB 8965
6536 Q$="YN":GOSUB 8910:ON Q% GOTO 6540,6540,6530
6540 FOR I%=CS% TO NZ%+CS%:ON Q% GOTO 6546,6550
6546 PRINT I%;
6550 CS%=I%:GOSUB 8927:IF I%=N% THEN 6650
6580 NEXT I%
6650 GOSUB 8925:GOTO 200
7000 PRINT:PRINT" *TOP OF STACK*":CS%=0
7030 GOSUB 8925:GOTO 200
7500 INPUT"LINE #";NZ%
7510 IF NZ%<1 THEN 7000
7530 IF NZ%>N% THEN NZ%=N%
7540 CS%=NZ%:GOSUB 8925:GOTO 200
8000 REM *PRINT *
8004 INPUT"CHAR WIDTH (NORMAL, CONDSD)";A$:GOSUB 8965
8005 Q$="NC":GOSUB 8910:CW=Q%:IF Q%>3 THEN 8004
8007 INPUT"DENSITY (NORM,EMPH,DBL)";A$:GOSUB 8965
8008 Q$="NED":GOSUB 8910:DE=Q%:IF Q%>3 THEN 8007
8010 INPUT"PRINT ENTIRE FILE";A$:GOSUB 8965
8020 Q$="YN":GOSUB 8910:ON Q% GOTO 8070,8040,8010
8040 INPUT"1ST LINE #";S0%
8050 INPUT"LAST LINE #";S1%
8060 GOTO 8071
8070 S0%=1:S1%=N%
8071 INPUT"DOUBLE-WIDTH CHARACTERS";A$:GOSUB 8965
8072 Q$="NY":GOSUB 8910:DW=Q%:IF Q%>2 THEN 8071
8075 IF CW=2 AND DE=2 THEN DE=3
8080 IF S0%<1 OR S0%>N% THEN 200
8090 IF S1%<S0% THEN 200
8091 IF S1%>N% THEN S1%=N%
8095 INPUT"AUTO FORM FEED";A$:GOSUB 8965
8096 Q$="YN":GOSUB 8910:IF Q%>2 THEN 8095
8106 PRINT:PRINT:YL=0
8110 PRINT TAB(5);"*TURN ON PRINTER, HIT RETURN*"
8120 LINE INPUT S$
8121 IF DE=3 THEN LPRINT CHR$(27);"G";
8122 IF DE=2 THEN LPRINT CHR$(27);"E";
8123 IF CW=2 THEN LPRINT CHR$(15);
8126 FOR CS%=S0% TO S1%
8127 IF DW=2 THEN LPRINT CHR$(14);
8140 LPRINT D$(CS%):YL=YL+1:IF YL<60 THEN 8143
8141 IF Q%=1 THEN YL=0:LPRINT CHR$(12)
8143 NEXT CS%
8145 IF Q%=1 THEN LPRINT CHR$(12)
8151 IF CW=2 THEN LPRINT CHR$(18)
8152 IF DE=2 THEN LPRINT CHR$(27);"F"
8153 IF DE=3 THEN LPRINT CHR$(27);"H"
8160 GOTO 7000
8750 REM KILL A FILE
8760 INPUT"DRIVE (A or B)";A$:GOSUB 8965
8770 DR$=A$:IF DR$<>"A" AND DR$<>"B" THEN 8760
8780 RESET:FILES (DR$+":*.*"):PRINT
8790 INPUT"READY TO DELETE A FILE";A$:GOSUB 8965
8800 Q$="YN":GOSUB 8910
8810 ON Q% GOTO 8820,200,8790
8820 LINE INPUT"FILE TO DELETE (NAME.TYP)";A$
8830 GOSUB 8965
8840 FILENAME$=DR$+":"+A$
8850 KILL FILENAME$:RESET:FILES (DR$+":*.*")
8860 PRINT:GOTO 200
8900 FOR Z=1 TO 1000:NL=NL:NEXT Z:RETURN
8910 A$=LEFT$(A$,1):Q%=LEN(Q$)+1
8912 FOR Z1%=1 TO (Q%-1)
8914 IF A$=MID$(Q$,Z1%,1) THEN Q%=Z1%
8916 NEXT Z1%:RETURN
8925 PRINT:PRINT"LINE #";CS%;"OF";N%
8927 PRINT D$(CS%):RETURN
8950 GOSUB 8955:PRINT TAB(10);"*";500-N%;" LINES FREE*"
8951 RETURN
8955 X=FRE("")+FRE(0)
8956 RETURN
8960 REM IF FNF(0)<F/1.9 THEN GOSUB 8955
8961 RETURN
8965 REM convert to upper case
8966 TEMP$=""
8967 FOR ZZ=1 TO LEN(A$)
8968 TEMP=ASC(MID$(A$,ZZ,1))
8969 IF TEMP>96 THEN TEMP=TEMP-96+64
8970 TEMP$=TEMP$+CHR$(TEMP)
8971 NEXT ZZ
8972 A$=TEMP$:RETURN
9000 REM RENAME A FILE
9010 INPUT"DRIVE (A or B)";A$:GOSUB 8965:DR$=A$
9020 Q$="AB":GOSUB 8910:ON Q% GOTO 9030,9030,9010
9030 RESET:FILES (DR$+":*.*"):PRINT
9040 INPUT"READY TO RENAME A FILE";A$:GOSUB 8965
9050 Q$="YN":GOSUB 8910:ON Q% GOTO 9060,200,9040
9060 LINE INPUT"OLD FILENAME (NAME.TYP)";A$:GOSUB 8965
9070 OLDNAME$=DR$+":"+A$
9080 LINE INPUT"NEW FILENAME (NAME.TYP)";A$:GOSUB 8965
9090 NEWNAME$=DR$+":"+A$
9100 NAME OLDNAME$ AS NEWNAME$
9110 RESET:FILES (DR$+":*.*"):PRINT
9120 GOTO 200
10000 REM undoc
10010 RESET
10020 PRINT "drive a:":PRINT
10030 FILES "A:*.*":PRINT:RESET
10040 PRINT:PRINT"drive b:":PRINT
10050 FILES "B:*.*":PRINT
10060 INPUT"drive (a,b)";A$
10070 A$=LEFT$(A$,1)+":":GOSUB 8965
10075 IF A$<>"A:"AND A$<>"B:"THEN 10060
10080 DR$=A$
10090 INPUT"filename (name.ext)";A$
10100 IF MID$(A$,LEN(A$)-3,1)<>"."THEN 10090
10110 GOSUB 8965:FILE$=DR$+A$
10120 OPEN "I",#1,FILE$
10130 TEMP$=""
10140 N%=N%+1
10150 IF N%<=NT% THEN 10190
10160 PRINT TAB(10);"*FILE IS TOO BIG*"
10170 N%=NT%
10180 GOTO 10200
10190 IF EOF(1) THEN 10200 ELSE 10240
10200 CLOSE
10210 RESET
10220 IF TEMP$<>"" THEN D$(N%)=TEMP$:PRINT D$(N%)
10230 GOTO 7000
10240 LINE INPUT #1,S$
10250 IF LEN(S$)>0 THEN 10260
10252 D$(N%)=TEMP$:PRINT D$(N%)
10260 FOR I%=1 TO LEN(S$)
10270 X=ASC(MID$(S$,I%,1))
10280 IF X>=128 THEN X=X-128
10290 IF X>31 THEN TEMP$=TEMP$+CHR$(X):GOTO 10500
10300 IF X<>13 THEN 10500
10310 D$(N%)=TEMP$:TEMP$="":PRINT D$(N%)
10320 N%=N%+1
10330 IF N%>NT% THEN 10160
10500 NEXT I%
10510 IF LEN(S$)=255 THEN 10190
10520 D$(N%)=TEMP$:TEMP$="":PRINT D$(N%)
10530 GOTO 10140
11000 REM GLOBAL CHANGE
11010 CS%=0:C%=0
11020 LINE INPUT"STRING TO FIND: ",S0$
11030 LINE INPUT"REPLACE WITH  : ",S1$
11040 IF INSTR(S1$,S0$)=0 THEN 11070
11050 PRINT"*THAT WILL CAUSE MANY ERRORS!*"
11060 GOSUB 8925:GOTO 200
11070 GOSUB 5530
11080 CS%=X1%
11090 IF X1%=0 THEN PRINT C%"strings changed":GOSUB 8925:GOTO 200
11100 C%=C%+1
11110 S2$=""
11120 IF S0%>1 THEN S2$=MID$(D$(CS%),1,S0%-1)
11130 S3$=MID$(D$(CS%),S0%+LEN(S0$))
11140 D$(CS%)=S2$+S1$+S3$:PRINT D$(CS%)
11150 CS%=CS%-1
11160 GOTO 11070
%),1,S0%-1)
11130 S3$=MID$(D$(CS%),S0%+LEN(S0$))
11140 D$(CS%)=S2$+S1$+S3$:PRINT D$(CS%)
11150 