10 'Program name--SEARCH         7/26/82
20 '
30 ' Demonstrates how a computer can extract information from data
40 '
50 '        Archie L. Abaire, Jr.
60 '        PO Box 29157
70 '        Richmond, Virginia  23233
80 '        (804) 740-7639
90 '
100 DIM L$(20),SEARCH(500),LETTER(40)
110 DEF FNXY$(Y,X) = CHR$(27)+"="+CHR$(Y+31)+CHR$(X+31)
120 PRINT CHR$(26)
130 PRINT "Letter Counter"
140 PRINT "July, 1982":PRINT
150 '
160 FOR I = 1 TO 500
170    SEARCH(I) = 0
180 NEXT
190 FOR I = 1 TO 40
200    LETTER(I) = 0
210 NEXT
220 PRINT "Enter low search character ";:LOW$ = INPUT$(1):PRINT LOW$
230 PRINT "Enter high search character ";:HIGH$ = INPUT$(1):PRINT HIGH$
240 PRINT "Display out of range characters? Y/N ";:FLAG$ = INPUT$(1):PRINT FLAG$
250 ' Enter words
260 GOSUB 490
270 '
280 PRINT CHR$(26);
290 PRINT:PRINT "*** LIST BEING SEARCHED ***"
300 GOSUB 600
310 GOSUB 750
320 PRINT
330 PRINT "TEST RESULTS"
340 PRINT "NUMBER OF CHARACTERS > ";HIGH$;" =";HIGH 
350 PRINT "NUMBER OF CHARACTERS < ";LOW$;" =";LOW
360 PRINT "NUMBER OF CHARACTERS =";C
370 PRINT:PRINT "Press any key to see table ";:A$ = INPUT$(1)
380 GOSUB 850
390 GOSUB 940
400 PRINT:PRINT "# =";SUB1;TAB(20);"# =";SUB2
410 PRINT:PRINT "TOTAL CHARACTER COUNT =";LETTERCOUNT
420 IF FLAG$="Y" THEN PRINT:PRINT "Press any key to see out of range characters ";:Q$ = INPUT$(1)
430 IF FLAG$="Y" THEN GOSUB 1040
440 XY$ = FNXY$(23,1):PRINT XY$;
450 PRINT "Do you want to do it again? ";:Q$ = INPUT$(1)
460 IF Q$ = "Y" THEN 120
470 IF Q$ <> "N" THEN 440
480 GOTO 740
490 PRINT CHR$(26);
500 PRINT "Enter words.  (<cr> when done)"
510 PRINT
520 N = 0
530 Q$ = " "
540 WHILE LEN(Q$) <> 0
550    N = N + 1
560    LINE INPUT "",Q$
570    L$(N) = Q$
580 WEND
590 RETURN
600 'SEARCH ARRAY
610 '
620 Z=1:C = 0:HIGH = 0:LOW = 0
630 FOR I=1 TO N
640    FOR J=1 TO LEN(L$(I))
650    TEST$=MID$(L$(I),J,1)
660    IF TEST$ > HIGH$ THEN HIGH=HIGH+1
670    IF FLAG$="Y" THEN IF TEST$ > HIGH$ THEN SEARCH(Z)=ASC(TEST$):Z=Z+1
680    IF TEST$ < LOW$ THEN LOW=LOW+1
690    IF FLAG$="Y" THEN IF TEST$ < LOW$ THEN SEARCH(Z)=ASC(TEST$):Z=Z+1
700    C=C+1:'TOTAL NUMBER OF CHARACTERS
710    NEXT
720 NEXT
730 RETURN
740 RUN "B:MENU
750 'COUNT ALL CHARACTERS
760 '
770 FOR I=1 TO N
780    FOR J=1 TO LEN(L$(I))
790    K%=ASC(MID$(L$(I),J)) - 64
800    IF K% < 1 THEN 820
810    LETTER(K%)=LETTER(K%)+1
820    NEXT
830 NEXT
840 RETURN
850 'PRINT TABLE OF CHARACTER COUNT
860 '
870 PRINT CHR$(26):PRINT "TABLE--CHARACTER COUNT"
880 PRINT
890 FOR I=1 TO 13
900    PRINT CHR$(I+64);" =";LETTER(I);
910    PRINT TAB(20);CHR$(I+13+64);" =";LETTER(I+13)
920 NEXT
930 RETURN
940 'COUNT ALL LETTERS IN TABLE
950 '
960 LETTERCOUNT = 0
970 SUB1 = 0:SUB2 = 0
980 FOR I=1 TO 26
990    LETTERCOUNT=LETTERCOUNT+LETTER(I)
1000    IF I<=13 THEN SUB1=SUB1+LETTER(I)
1010    IF I>13 THEN SUB2=SUB2+LETTER(I)
1020 NEXT 
1030 RETURN
1040 'PRINT EXTRA CHARACTERS
1050 '
1060 PRINT CHR$(26)
1070 PRINT "OTHER CHARACTERS":PRINT
1080 X = 1:Y = 3
1090 FOR I = 1 TO Z
1100    IF I MOD 20 = 0 THEN X = X + 10:Y = 2
1110    Y = Y + 1
1120    XY$ = FNXY$(Y,X)
1130    PRINT XY$;:PRINT USING "###";I;
1140    XY$ = FNXY$(Y,X+4)
1150    PRINT XY$;CHR$(SEARCH(I));
1160 NEXT
1170 RETURN
30    PRINT XY$;:PR