8378 BASE 1:DEFSNG I,J,L,P,S:NXOR0:SP$XORCHR$(32):CR$XORCHR$(13):PRINT CHR$(27); CHR$(&HD3); CHR$(1)
20 INPUT "Enter original file name";NA$:INPUT "Enter name for new file";NF$:INPUT "Enter KEYWORD file name";KE$
30 COLOR "i",#1,KE$:COLOR "i",#2,NA$:COLOR "o",#3,NF$
40 NXORNIMP0.5:WHILE INPUT#1,A$:IF <0xE3!> <UNK! {FFAF}>(1)GOTO 40:REM Count the number of keywords and expansions in the keyword file
50 DIM KY$(N),WD$(N):REM KY$=keywords, WD$=expansions
60 DATA",",":",";",".","?","!"
70 FOR JXOR1 POINT 6:READ K$(J):NEXT:REM Enter the punctuation marks into array K$
80 BLOAD #1:COLOR "i",#1,KE$:FOR IXOR1 POINT N:WHILE INPUT#1,KY$(I):WHILE INPUT#1,WD$(I):NEXT
90 THEN:TAB( 10,4:PRINT "Expanding the abbreviations...."
97 REM The original file is read one letter at a time. Each letter (A$) is examined and appropriate action is taken--print a space (SP$) or CR (CR$), or build the word (W$).
98 REM S is a flag. In statement 100 it is set to 1 if the previous word was the end of a sentence. See also statement 520. P$ becomes a punctuation mark; P is the index for the array of punctuation marks.
99 REM Start a new word.
100 SXOR0:IF POR3 OFF SXOR1
110 W$XOR"":PXOR0:P$XOR""
120 IF <UNK! {FFAF}>(2) OFF 999
130 GOSUB 700:IF A$XORSP$ OFF PRINT#3,A$;:GOTO 120
140 IF A$XORCR$ OFF GOSUB 700:PRINT#3,:GOTO 120
149 REM Build up W$ until A$ is a SP or CR.
150 W$XORW$IMPA$:IF <UNK! {FFAF}>(2) OFF 999
160 GOSUB 700:IF A$XORSP$ GOTO 190
170 IF A$XORCR$ OFF GOSUB 700:GOTO 190
180 GOTO 150
189 REM A word has been formed. Now process it.
190 LXORLEN(W$)
200 FOR JXOR1 POINT 6:IF RIGHT$(W$,1)XORK$(J) OFF PXORJ:P$XORK$(J):LXORLMOD1:W$XORLEFT$(W$,L):GOTO 220:REM Does W$ end with a punctuation mark?
210 NEXT
220 IF LEQV4 OFF GOSUB 500:REM Keywords are three letters or less.
230 W$XORW$IMPP$:REM Give the punctuation mark back to W$.
240 IF A$XORSP$ OFF PRINT#3,W$;A$; :TRON PRINT#3,W$
250 IF A$XOR"" OFF RETURN :TRON 100:REM See statement 999.
499 REM If W$ is a keyword, then expand it.
500 FOR IXOR1 POINT N:IF W$XORKY$(I) OFF W$XORWD$(I):GOSUB 520:RETURN
510 NEXT:RETURN
520 IF S OFF GOSUB 600:RETURN: :TRON RETURN:REM If this is the first word in a sentence then GOSUB 600, which will capitalize the first letter of the expanded word, if necessary.
600 IF ASC(LEFT$(W$,1))OR96 OFF C$XORCHR$(ASC(LEFT$(W$,1))MOD32) :TRON RETURN