1010 ' initialization 1020 DEFINT A-Z 1030 OPTION BASE 0 1040 ' 1050 ' integers 1060 A = 0 ' or any number 1070 LC = 0 ' line counter 1080 WC = 0 ' word counter 1090 SC = 0 ' sentence counter 1100 IS = 0 ' currently in a sentence? 1110 IW = 0 ' currently building a word? 1120 ' 1130 ' integer arrays 1140 DIM PUN(256) ' storage for characters 1150 DIM WDL(3000) ' word length list 1160 ' 1170 ' strings 1180 F$ = "" ' initial null string for filename 1190 RT$= CHR$(13) + CHR$(10) 1200 R1$= " FOG Index: ##.#" 1210 R2$= " Total words: ####.0 Sentences: ####.0 Average w/s: ####.#" 1220 R3$= "_% Long words: ###.# Medium: ###.# Short: ###.#" 1230 ' 1240 ' string arrays 1250 DIM TEXT$(128) ' storage for text lines 1260 ' 1270 ' get the filename from command line, if possible 1280 ZERO = PEEK(0) ' what's the code at zero? 1290 POKE 0, &HC9 ' make it a RETurn, just in case 1300 CALL CTAIL(F$) ' call routine if defined, else will RETurn from 0 1310 POKE 0, ZERO ' restore original code at zero 1320 ' 1330 ' or you could get it this way 1340 '@getfile 1350 IF F$ = "" THEN INPUT "File to check"; F$ 1360 ' 1370 ' open it, and make sure it's valid 1380 OPEN "R", 1, F$, 128 1390 FIELD 1, 128 AS BLOCK$ 1400 IF LOF(1) > 0 THEN 1490 ' @READFILE 1410 ' 1420 ' reset and try again if null file 1430 PRINT CHR$(34) F$ CHR$(34) " is an empty file." 1440 CLOSE 1450 KILL F$ 1460 F$ = "" 1470 GOTO 1340 ' @GETFILE 1480 ' 1490 '@readfile 1500 PRINT "Reading, "; 1510 FOR LC = 1 TO LOF(1) 1520 GET 1, LC 1530 TEXT$(LC) = BLOCK$ 1540 NEXT 1550 CLOSE 1560 ' 1570 '@fixup 1580 IF LEN(TEXT$(LC))=0 THEN LC=LC-1 : GOTO 1570 ' @FIXUP 1590 ' 1600 ' build word list 1610 PRINT "analyzing: pass 1, "; 1620 FOR CL = 1 TO LC 1630 FOR CP = 1 TO 128 1640 A = ASC(MID$(TEXT$(CL),CP,1)) ' get character from block 1650 A = A AND 127 ' mask off unwanted bit 1660 IF NOT ((A>64 AND A<91)OR(A>96 AND A<123)OR(A>47 AND A<57)OR(A=39)) THEN 1730 ' @SENTENCE 1670 IF (NOT IW) THEN WC=WC+1 1680 IF (NOT IS) THEN SC=SC+1 1690 IS=-1 1700 IW=-1 1710 WDL(WC)=WDL(WC)+1 1720 GOTO 1790 ' @NEXTPUN 1730 '@sentence 1740 IF (A=33)OR(A=46)OR(A=63) THEN IS=0 1750 IW=0 1760 PUN(A)=PUN(A)+1 1770 ' check for exit conditions; end of file or enough words 1780 IF (A=26) OR (WC=2999) OR (WC>2980 AND (NOT IS)) THEN CP=128:CL=LC 1790 '@nextchar 1800 NEXT CP 1810 NEXT CL 1820 ' 1830 ' word lengths calculations 1840 PRINT "pass 2. "; 1850 FOR CP=1 TO WC 1860 IF WDL(CP)=>5 AND WDL(CP)<10 THEN MD = MD + 1 1870 IF WDL(CP)=8 THEN MW = MW + 1 1880 IF WDL(CP)=9 THEN LW = LW + 1 1890 IF WDL(CP)>9 THEN SF = SF + 1 1900 NEXT 1910 ' 1920 ' convert integer counter to single precision 1930 PRINT "Calculating: "; 1940 WC! = CSNG(WC) 1950 SC! = CSNG(SC) 1960 MD! = CSNG(MD) 1970 MW! = CSNG(MW) 1980 LW! = CSNG(LW) 1990 SF! = CSNG(SF) 2000 ' 2010 ' final calculations 2020 AV! = WC!/SC! 2030 SF! = SF!+(LW!*.8)+(MW!*.45) 2040 LW! = (SF!*100)/WC! 2050 MW! = (MD!*100)/WC! 2060 SW! = 100-(LW!+MW!) 2070 FI! = (AV!+LW!)*.4 2080 ' 2090 ' report results 2100 PRINT RT$ 2110 PRINT USING R1$; FI! 2120 PRINT USING R2$; WC, SC, AV! 2130 PRINT USING R3$; LW!, MW!, SW! 2140 ' 2150 PRINT RT$ "Comments: "; 2160 ' 2170 IF WC <100 THEN PRINT RT$; " Small sample, results may be off."; : SG = -1 2180 IF FI!< 6 THEN PRINT RT$; " Low FOG Index; simplistic or childish style?"; : SG=-1 2190 IF FI!> 10 THEN PRINT RT$; " High FOG Index; complex or overbearing style?"; : SG=-1 2200 IF AV!> 18 THEN PRINT RT$; " Long sentences; verbose?"; : SG=-1 2210 IF AV!< 8 THEN PRINT RT$; " Short sentences; choppy?"; : SG=-1 2220 IF SW!< 50 THEN PRINT RT$; " Less than 50% short words; try using use fewer big words."; : SG=-1 2230 IF PUN(33)*8 > SC THEN PRINT RT$; PUN(33) "exclamations; over-excited?"; : SG=-1 2240 IF PUN(63)*5 > SC THEN PRINT RT$; PUN(63) "questions; rhetorical?"; : SG=-1 2250 IF PUN(59)*3 > SC THEN PRINT RT$; PUN(59) "semicolons, possible places to break long sentences."; : SG=-1 2260 IF PUN(44)*1 > SC THEN PRINT RT$; PUN(44) "commas, possible places to break sentences."; : SG=-1 2270 IF PUN(40)*4 > SC THEN PRINT RT$; " At least" PUN(40) "parenthetical remarks; could any be independent sentences?"; : SG=-1 2280 IF PUN(40)<>PUN(41) THEN PRINT RT$; PUN(40) "Open parens," PUN(41) "close parens; unbalanced?"; : SG=-1 2290 ' 2300 IF SG=0 THEN PRINT "None."; 2310 ' 2320 END