50 REM Make sure you create a file called WORDS.TXT. It should initially
60 REM contain 512 carriage returns, as no words will be known at the start.
70 REM The program learns words as you teach them to it, so be patient for the
80 REM first few tries and let it learn some words. Soon the dictionary will
90 REM be custom tailored to your needs.
100 PRINT TAB(21);"Loading dictionary into memory"
110 OPEN "WORDS.TXT" FOR INPUT AS #1
120 FOR J=1 TO 512:INPUT #1,A$(J):NEXT :CLOSE
130 CLS
140 INPUT "File name:",NF$
150 I=1:OPEN NF$ FOR INPUT AS #1
160 IM=I-128*INT((I-1)/128):LINE INPUT #1,B$(IM)
170 IF I<=128*M THEN 200
180 IF EOF(1) THEN CLOSE:E=0:GOTO 210
190 E=1:IF IM=128 THEN CLOSE:GOTO 210
200 I=I+1:GOTO 160
210 B$=STRING$(255,32):LOCATE ,,0:IF M=0 THEN CLS
220 IF M=0 THEN CLS:PRINT CHR$(205);CHR$(205);CHR$(16);" Press ";CHR$(17);CHR$(196);CHR$(217);" to enter word in dictionary.":PRINT CHR$(205);CHR$(205);CHR$(16);" Press [SPACE BAR] to bypass word.":PRINT
230 FOR J=1 TO IM:CR=CSRLIN:CC=POS(0)
240 LOCATE 1,76:PRINT STR$(J+128*M);:LOCATE CR,CC
250 LB=LEN(B$(J)):IF LB=0 THEN 370
260 C=0:L1=1:FOR K=1 TO LB:A=ASC(MID$(B$(J),K,1))
270 IF A>127 OR A<32 THEN A=32
280 PRINT CHR$(A);:IF A>90 THEN A=A-32
290 MID$(B$,K,1)=CHR$(A)
300 IF A<65 THEN IF K>L1+1 THEN C=K-L1:C$=MID$(B$,L1,C)
310 IF A>64 AND A<97 AND K=LB THEN C=K-L1+1:C$=MID$(B$,L1,C)
320 IF A<65 OR K=LB THEN L1=K+1
330 IF C<2 THEN 360
340 IF RIGHT$(C$,1)="S" THEN C$=LEFT$(C$,C-1):C=C-1:IF C<2 THEN 360
350 WC=WC+1:GOSUB 430:C=0
360 NEXT
370 PRINT :NEXT :IF E THEN M=M+1:GOTO 150
380 PRINT :PRINT ,"Word count =";WC
390 C$="":PRINT ,"Updating dictionary on disk"
400 OPEN "WORDS.TXT" FOR OUTPUT AS #1
410 FOR JH=1 TO 512:PRINT #1,A$(JH):NEXT :CLOSE
420 CLEAR:END
430 H=0:FOR JH=1 TO C:H=H+ASC(MID$(C$,JH,1)):NEXT
440 H=H-512*INT(H/512)+1
450 L=LEN(A$(H)):IN=INSTR(A$(H),C$):IF IN THEN 510
460 PRINT "<?>";:BEEP
470 U$=INPUT$(1):IF U$=" " THEN IF INP(957)=223 THEN LPRINT USING "#####";J+128*M;:LPRINT ": ";LEFT$(B$(J),L1-1):GOTO 500 ELSE 500
480 IF U$<>CHR$(13) THEN 470
490 IF L+C<100 THEN A$(H)=C$+" "+A$(H) ELSE MID$(A$(H),C+2,99-C)=MID$(A$(H),1,99-C):GOSUB 540
500 FOR JH=1 TO 3:PRINT CHR$(29);CHR$(32);CHR$(29);:NEXT :RETURN