5 PRINT"A text analysis program by Keith M. Simons, and provided with his compliments. 6 PRINT"Copyright 1989.":PRINT 10 PRINT"This is the ULTIMATE word count program. You see, it doesn't just count words. 20 PRINT"It counts the average words in a sentence. The average letters in each word. 30 PRINT"The number of occurances of each word which occurs more than 4 times. Works out 40 PRINT"the longest word in the passage. The average length of words. Draws graphs 50 PRINT"and charts all about it. And does literally dozens of other things as well. 60 PRINT:PRINT"It's designed to work with SIMPLE TEXT FILES created by Locoscript's MAKE ASCII 70 PRINT"FILE option (f7 or f1 from the disc management screen). On other files counts 80 PRINT"relating to number of sentences and sentence length etc. may be incorrect. 90 PRINT:PRINT"To use it, just type in the full filename when requested, eg. M:FILE.ASC for 100 PRINT"a file called FILE.ASC on disc M:. While it counts, it shows you how far through 110 PRINT"the file it has got. When the bar at the bottom of the screen has filled up, the 120 PRINT"count has finished. (Yes, it does take quite a while.) 130 PRINT:PRINT"You are not recommended to use this program on files exceeding 16K in length 140 PRINT:PRINT"Press any key to begin.";INPUT$(1) 1000 GOTO 1100 1010 INPUT;"Next number... ",b#:total#=total#+b#:PRINT TAB (60);USING "###,###,###.######";total#:GOTO 1010 1020 LINE INPUT "* ",a$:LPRINT a$:GOTO 1020:REM twenty spaces. 1030 PRINT TAB (20);CHR$(27)+"p";"The Complete Ascii Character Set - values 32 to 255";CHR$(27)+"q":PRINT:FOR a=32 TO 255:PRINT USING "###";a;:PRINT " is ";CHR$(a);CHR$(149);:NEXT:END 1040 PRINT TAB (25);CHR$(27)+"p";"Graphics available in the Ascii Character Set";CHR$(27)+"q":PRINT:FOR a=128 TO 159:PRINT USING "###";a;:PRINT " is ";CHR$(a);CHR$(149);:NEXT:END 1050 PRINT CHR$(27)+"p";"Ten lines of memory are available for your use.";CHR$(27)+"q":FOR a=1 TO 10:PRINT a;">";:LINE INPUT a$(a):NEXT:PRINT "Stored ten lines." 1060 PRINT "Save, Display or Print?":a$=UPPER$(INPUT$(1)):IF a$="S" THEN INPUT "filename? ",a$:OPEN "o",1,a$:FOR a=1 TO 10:PRINT #1 a$(a):NEXT:CLOSE:END:ELSE IF a$="P" THEN FOR a=1 TO 10:LPRINT a$(a):NEXT:END:ELSE FOR a=1 TO 10:PRINT a$(a):NEXT:END 1070 a$="":PRINT "Please press the key of your choice.":WHILE a$="":a$=INKEY$:WEND:PRINT a$;" has an ascii value of";ASC(a$):GOTO 1070 1080 a$="":total#=0:a=0:b#=0:PRINT "Calculate, Typewriter, Ascii characters, Key's ascii value, Store ten lines, Use ten lines or Graphics in ascii?" 1090 ON INSTR("CTAKSUG",UPPER$(INPUT$(1))) GOTO 1010,1020,1030,1070,1050,1060,1040:END 1100 PRINT CHR$(27)+"E":DEF FNtab$(x,y)=CHR$(27)+"Y"+CHR$(y+32)+CHR$(x+32) 1110 DEF FNmdl$(y,word$)=FNtab$(ROUND(45-(LEN(word$)/2)),y)+word$ 1120 DEF FNbox$(y,word$)=FNmdl$(y,CHR$(134)+STRING$(LEN(word$),CHR$(138))+CHR$(140))+FNmdl$(y+1,CHR$(133)+word$+CHR$(133))+FNmdl$(y+2,CHR$(131)+STRING$(LEN(word$),CHR$(138))+CHR$(137)) 1130 DEF FNboxA$(y,word$)=FNmdl$(y,CHR$(150)+STRING$(LEN(word$),CHR$(154))+CHR$(156))+FNmdl$(y+1,CHR$(149)+word$+CHR$(149))+FNmdl$(y+2,CHR$(147)+STRING$(LEN(word$),CHR$(154))+CHR$(153)) 1140 DEF FNboxB$(y,word$)=CHR$(27)+"p"+FNbox$(y,word$)+CHR$(27)+"q" 1150 DEF FNfil$(drive$,name$)=STRIP$(FIND$(drive$+":"+name$)) 1160 DEF FNbar$(word$,sc,sz,y)=FNtab$(20,y)+CHR$(151)+STRING$(ROUND(sz*60/sc),CHR$(154))+CHR$(156)+FNtab$(20,y+1)+CHR$(149)+FNtab$(ROUND(sz*60/sc)+21,y+1)+CHR$(149)+FNtab$(20,y+2)+CHR$(151)+STRING$(ROUND(sz*60/sc),CHR$(154))+CHR$(153)+FNtab$(0,y+1)+word$ 1170 DEF FNchs$(option$)=RIGHT$(LEFT$(option$,INSTR(UPPER$(option$),LEFT$(UPPER$(INKEY$)+"a",1))),1) 1180 DEF FNyes=INSTR(UPPER$(INPUT$(1)),"Y")*-1 1190 DEF FNins$(main$,insert$,posn)=LEFT$(main$,posn)+insert$+MID$(main$,posn+1) 1200 DEF FNdel$(main$,posn,number)=LEFT$(main$,posn-1)+MID$(main$,posn+number) 1210 DEF FNrep$(main$,insert$,posn)=LEFT$(main$,posn-1)+insert$+MID$(main$,posn+LEN(insert$)) 1220 DEF FNtme$=HEX$(PEEK(64502!),2)+":"+HEX$(PEEK(64503!),2)+":"+HEX$(PEEK(64504!),2) 1230 DEF FNinp$=UPPER$(INPUT$(1,1)) 1240 DEF FNfle$=FNboxA$(25,STRING$(ROUND(LOC(1)/LOF(1)*50),"#")+SPACE$(ROUND(50-(LOC(1)/LOF(1)*50)))):' one more braket 1250 x$=CHR$(27):PRINT FNbox$(0,"Which file to check?"):FILES:PRINT:PRINT:INPUT "Which file? ",file$ 1260 OPEN "I",1,file$ 1270 BUFFERS 10:CREATE 2,"M:A.$$$","M:B.$$$",2,4:FIELD 2,2 AS G$ 1280 DIM wl%(10),sl%(80):t=-1 1290 ew%=t:es%=t:ep%=t:testW$=" "+CHR$(10)+CHR$(13)+CHR$(12)+"([{)]}," 1300 PRINT x$;"E";FNboxB$(0,"Checking file: "+UPPER$(file$)) 1310 'LOOP 1320 IF EOF(1) THEN GOSUB 1510:END 'That is, the display routines 1330 z$=FNinp$ 1340 IF INSTR(testW$,z$) THEN GOSUB 1450:GOTO 1310:'prepare to expect something. 1350 IF INSTR(".?!",z$) AND NOT EOF(1) THEN z$=FNinp$:IF z$=" " OR z$=CHR$(10) OR z$=CHR$(12) OR z$=CHR$(13) OR z$="'" OR z$=CHR$(34) THEN es%=t:GOSUB 1450:GOTO 1310 ELSE w.rd$=w.rd$+"." 1360 IF INSTR("1234567890",z$) THEN digit%=digit%+1 1370 IF INSTR("ABCDEFGHIJKLMNOPQRSTUVWXYZ",z$) THEN 1380 ELSE GOTO 1310 1380 IF ew% THEN ew%=0:cws%=cws%+1:c.w%=c.w%+1:c=LEN(w.rd$):wl%(MIN(c,10))=wl%(MIN(c,10))+1:GOSUB 1490:IF LEN(w.rd$)>LEN(ma$) THEN ma$=w.rd$:w.rd$="":ELSE w.rd$="" 1390 w.rd$=w.rd$+z$ 1400 alpha%=alpha%+1 1410 IF es% THEN es%=0:c.s%=c.s%+1:GOSUB 1440:IF cws%>mc% THEN mc%=cws%:cws%=0:ELSE cws%=0 1420 IF ep% THEN ep%=0:cp%=cp%+1 1430 GOTO 1310 1440 c=MIN(cws%,80):sl%(c)=sl%(c)+1:RETURN :'That is, sentence length. 1450 ew%=t 1460 IF INSTR(CHR$(13)+CHR$(10),z$) THEN ep%=t:es%=t 1470 IF c.s%>zy% THEN zy%=c.s%:PRINT FNboxA$(15,"Working on sentence no. "+STR$(c.s%)) ;FNfle$ 1480 RETURN 1490 IF SEEKKEY(2,2,0,w.rd$)<>0 THEN LSET g$=MKI$(1):rc%=ADDREC(2,2,0,w.rd$):RETURN 1500 GET 2:LSET g$=MKI$(CVI(g$)+1):PUT 2:RETURN 1510 PRINT x$+"E"+x$;"H";FNboxA$(0,"Analysis of file "+UPPER$(file$)):CLOSE 1 1520 PRINT FNmdl$(5,"Contains"+STR$(alpha%)+" letters.") 1530 PRINT FNmdl$(6,STR$(digit%)+" numbers.") 1540 PRINT FNmdl$(7,STR$(c.w%)+" words.") 1550 PRINT FNmdl$(8,STR$(c.s%)+" sentences.") 1560 PRINT FNmdl$(9,STR$(cp%)+" paragraphs.") 1570 PRINT:PRINT:PRINT "On average:" 1580 PRINT c.w%/c.s%"words per sentence." 1590 PRINT c.w%/cp%"words per paragraph." 1600 PRINT alpha%/c.w%"letters per word." 1610 PRINT alpha%/c.s%"letters per sentence." 1620 PRINT FNtab$(50,12);"Longest word was ";ma$ 1630 PRINT FNtab$(50,13);"with"LEN(ma$)"letters. 1640 PRINT FNtab$(50,15);"Longest sentence had"mc%"words." 1650 PRINT FNmdl$(25,"Press any key to continue, and see the word length breakdown."):z$=INPUT$(1) 1660 PRINT x$+"E";FNbox$(0,"Comparison of letters per word:"):scale=MAX(wl%(1),wl%(2),wl%(3),wl%(4),wl%(5),wl%(6),wl%(7),wl%(8),wl%(9),wl%(10)) 1670 FOR c=2 TO 10:IF c<>10 THEN PRINT FNbar$(STR$(c)+" letters - "+STR$(wl%(c)),scale,wl%(c),(c*3)-3) 1680 IF c=10 THEN PRINT FNbar$(STR$(c)+"+ letters - "+STR$(wl%(c)),scale,wl%(c),(c*3)-3) 1690 NEXT 1700 PRINT FNmdl$(29,"Press any key to continue, and see the sentence length breakdown."):z$=INPUT$(1) 1710 count=0:FOR c=0 TO 80:count=MAX(sl%(c),count):NEXT 1720 PRINT x$+"E";x$+"H" 1730 FOR c=1 TO 0.05 STEP -0.05:aa=count*c:FOR ab=0 TO 80 1740 IF sl%(ab)>=aa THEN PRINT x$+"p "+x$+"q";: ELSE PRINT " "; 1750 NEXT ab:PRINT:NEXT 1760 FOR a=1 TO 8:PRINT "|....:....";:NEXT 1770 PRINT "|";:FOR a=5 TO 80 STEP 5:PRINT TAB(a);a;:NEXT:PRINT "+" 1780 PRINT FNboxA$(25,"Analysis of words per sentence.") 1790 WHILE INKEY$="":WEND 1800 PRINT x$"E"x$"H"; 1810 rc%=SEEKRANK(2,2,0) 1820 WHILE rc%<102 1830 GET 2 1840 IF CVI(g$)>4 THEN PRINT FETCHKEY$(2);TAB(30);CVI(g$) 1850 rc%=SEEKNEXT(2,2) 1860 WEND 1865 PRINT:PRINT"See it again? (y/n)":IF FNyes THEN 1510 1870 CLOSE:ERA M:*.$$$ 25000 IF FIND$("M:$$$$$$$$.&&&")<>"" THEN OPTION STOP:PRINT "[Press any key to return to main menu or press (STOP) to stop]":z$=INPUT$(1):RUN "M:$$$$$$$$.&&&":ELSE END O