8-Bit Software Online Conversion

VIEW SPELLCHECKER - Listing

10REM SPELL 20REM A spelling check program 30REM For B/B+/E/M/C (with discs) 40REM by Alan Blundell 50REM (c) 1989 60: 70*FX 3 0 80MODE 7 90PROCinit 100REPEAT 110PROCopenfile 120REPEAT 130PROCaddtolist(FNreadword) 140UNTIL eof% 150CLOSE #handle% 160PROCcheck 170PROCaction 180PRINT ''TAB(9)"Press any key .. "; 190throwaway$=FNgetkey 200UNTIL 0 210END 220: 230DEFPROCinit 240PRINT '"SPELLCHECK" 250PRINT "``````````" 260VDU 28,0,24,39,4 270size%=7*1024 280DIM listbuf% size% 290listbufend%=listbuf%+size%-1 300DIM wordbuf% 100 310maxunits%=28 320DIM dictbuf% maxunits%*256 330DIM index% 211 340DIM block% 12 350osgbpb=&FFD1 360PROCasm 370ON ERROR PROCerror:END 380ENDPROC 390: 400DEFPROCopenfile 410REPEAT 420REPEAT 430CLS 440PRINT TAB(8,15)"Press ESCAPE to qui t." 450PRINT TAB(8,16)"Press RETURN for me nu" 460PROCcursor(1) 470INPUT TAB(0,1)"Filename : "filename $ 480PROCcursor(0) 490IF LEN(filename$)=0 PROCutilities 500UNTIL LEN(filename$)>0 510PRINT TAB(8,15) SPC(21) 520PRINT TAB(8,16) SPC(21) 530handle%=OPENIN(filename$) 540UNTIL handle%>0 550eof%=FALSE 560listtop%=listbuf% 570wordcount%=0 580unique%=0 590PRINT TAB(0,3)"Number of words : 0" 600PRINT TAB(0,4)"Number of unique wor ds : 0" 610ENDPROC 620: 630DEFPROCutilities 640CLS 650PRINT TAB(13)"UTILITIES" 660PRINT TAB(13)"`````````" 670PRINT '"1. Remove word(s) from dict ionary" 680PRINT '"2. Convert dictionary to te xt file" 690PRINT '"3. Convert text file to dic tionary" 700PRINT '"4. Create new dictionary" 710PRINT '"5. OS '*' command" 720PRINT '"6. Back to spellcheck" 730PRINT ''"Choose (1-6) : "; 740PROCcursor(1) 750*FX 21 0 760REPEAT 770key$=GET$ 780UNTIL INSTR("123456*"+CHR$(13),key$ ) 790PROCcursor(0) 800PRINT key$ 810IF key$="1" THEN CHAIN "DicWipe" 820IF key$="2" THEN CHAIN "DicConv" 830IF key$="3" THEN CHAIN "TxtConv" 840IF key$="4" THEN CHAIN "MakeDic" 850IF key$="5" THEN PROCoscli 860IF key$="*" THEN PROCoscli 870ENDPROC 880: 890DEFFNreadword 900LOCAL char%,word$ 910REPEAT 920char%=(BGET #handle%) AND 223 930UNTIL (char%>64 AND char%<91) OR EO F #handle% 940IF EOF #handle% eof%=TRUE : = "" 950word$=CHR$(char%) 960REPEAT 970char%=(BGET #handle%) AND 223 980IF (char%>64 AND char%<91) word$=wo rd$+CHR$(char%) 990UNTIL char%<65 OR char%>90 OR EOF # handle% 1000IF EOF #handle% eof%=TRUE 1010wordcount%=wordcount%+1 1020PRINT TAB(18,3);wordcount%; 1030=word$ 1040: 1050DEFPROCaddtolist(word$) 1060LOCAL length% 1070IF LEN(word$)<2 ENDPROC 1080IF FNfindword(listbuf%,listtop%,wor d$) ENDPROC 1090listptr%=!buffptr% 1100length%=LEN(word$)+1 1110IF length%>listbufend%-listtop% PRO Cbufferfull:ENDPROC 1120IF listtop%=listptr% GOTO 1170 1130!source%=listptr% 1140!dest%=listptr%+length% 1150!len%=listtop%-listptr% 1160CALL move 1170listtop%=listtop%+length% 1180$listptr%=word$ 1190unique%=unique%+1 1200PRINT TAB(25,4);unique% 1210ENDPROC 1220: 1230DEFPROCbufferfull 1240PRINT TAB(0,6)"Buffer full - closin g file." 1250PRINT "Words already read will be c hecked." 1260PRINT "Press a key to continue .. " ; 1270eof%=TRUE 1280throwaway$=FNgetkey 1290PRINT TAB(0,6) SPC(110) 1300ENDPROC 1310: 1320DEFPROCcheck 1330PRINT TAB(0,5)"Checking against dic tionary"; 1340PRINT TAB(0,6)"Words still to check : ";unique% 1350handle%=OPENIN("Diction") 1360IF handle%=0 PRINT '''"No dictionar y!":END 1370PROCgbpb(3,handle%,index%,212,0) 1380listptr%=listbuf% 1390oldletter%=-1 1400REPEAT 1410letter%=?listptr%-65 1420word$=$(listptr%+1) 1430IF letter%<>oldletter% PROCloaddict (letter%):oldletter%=letter% 1440IF FNfindword(dictbuf%,dicttop%,wor d$) PROCremove(listptr%) ELSE listptr%=l istptr%+LEN($listptr%)+1 1450UNTIL listptr%=listtop% 1460IF unique%>1 PRINT ';unique%;" word s not in dictionary :" 1470IF unique%=1 PRINT '"One word not i n dictionary :" 1480IF unique%=0 PRINT '"All words foun d in dictionary" 1490IF unique%>0 PROClist 1500CLOSE #handle% 1510ENDPROC 1520: 1530DEFPROCremove(listptr%) 1540length%=LEN($listptr%)+1 1550IF listptr%+length%=listtop% GOTO 1 600 1560!source%=listptr%+length% 1570!dest%=listptr% 1580!len%=listtop%-listptr%-length% 1590CALL move 1600listtop%=listtop%-length% 1610unique%=unique%-1 1620PRINT TAB(23,6);unique%;" " 1630ENDPROC 1640: 1650DEFPROClist 1660VDU 14 1670listptr%=listbuf% 1680PRINT 1690REPEAT 1700IF POS>(38-LEN($listptr%)) PRINT 1710PRINT $listptr%;" "; 1720listptr%=listptr%+LEN($listptr%)+1 1730UNTIL listptr%=listtop% 1740VDU 15 1750PRINT 1760ENDPROC 1770: 1780DEFPROCaction 1790LOCAL key$,corrections% 1800IF unique%=0 ENDPROC 1810PRINT '"Add words to dictionary or make"'"corrections? (y/n) : "; 1820key$=FNgetkey 1830IF key$="Y" PRINT "Yes" ELSE PRINT "No" 1840IF key$<>"Y" ENDPROC 1850handle%=OPENUP("Diction") 1860PROCgbpb(3,handle%,index%,212,0) 1870oldletter%=-1 1880PROCexecfileinit 1890corrections%=0 1900listptr%=listbuf% 1910PRINT '"A(dd), C(orrect) or I(gnore ) :"' 1920REPEAT 1930word$=$listptr% 1940PRINT word$;" (A/C/I) : "; 1950key$=FNgetkey 1960IF key$="A" PRINT "Add":PROCaddword (word$) 1970IF key$="C" PRINT "Correct":PROCcor rect(word$):corrections%=corrections%+1 1980IF INSTR("AC",key$)=0 PRINT "Ignore " 1990listptr%=listptr%+LEN($listptr%)+1 2000UNTIL listptr%=listtop% 2010PROCsavedict 2020PROCgbpb(1,handle%,index%,212,0) 2030CLOSE #handle% 2040PROCexecfileend 2050IF corrections%>0 THEN PROCcallwp 2060ENDPROC 2070: 2080DEFPROCaddword(word$) 2090letter%=ASC(word$)-65 2100word$=RIGHT$(word$,LEN(word$)-1) 2110IF letter%<>oldletter% PROCchangedi ct 2120IF FNfindword(dictbuf%,dicttop%,wor d$) ENDPROC 2130length%=LEN(word$)+1 2140IF length%>(dictsize%-dictlen%) PRI NT '"Not enough room - word not added!": ENDPROC 2150dictptr%=!buffptr% 2160IF dicttop%=dictptr% GOTO 2210 2170!source%=dictptr% 2180!dest%=dictptr%+length% 2190!len%=dicttop%-dictptr% 2200CALL move 2210dicttop%=dicttop%+length% 2220$dictptr%=word$ 2230dictlen%=dictlen%+length% 2240index%!(letter%*8+4)=dictlen% 2250ENDPROC 2260: 2270DEFPROCcorrect(word$) 2280LOCAL correct$,key$ 2290PRINT "Please type the correct spel ling"'word$; 2300*FX 21 0 2310PROCcursor(1) 2320INPUT " : "correct$ 2330PROCcursor(0) 2340IF correct$="" ENDPROC 2350PROCexec("CHANGE "+word$+" "+correc t$) 2360PRINT "Add to dictionary? (y/n) : " ; 2370key$=FNgetkey 2380IF key$="Y" PRINT "Yes" ELSE PRINT "No" 2390IF key$="Y" PROCaddword(correct$) 2400ENDPROC 2410: 2420DEFPROCexecfileinit 2430handle2%=OPENOUT("CORRECT") 2440PROCexec("*WORD") 2450PROCexec("LOAD "+filename$) 2460ENDPROC 2470: 2480DEFPROCexec(comm$) 2490LOCAL pos% 2500FOR pos%=1 TO LEN(comm$) 2510BPUT #handle2%,ASC(MID$(comm$,pos%, 1)) 2520NEXT 2530BPUT #handle2%,13 2540ENDPROC 2550: 2560DEFPROCexecfileend 2570PROCexec("SAVE "+filename$) 2580PROCexec("*BASIC") 2590PROCexec("CHAIN ""SPELL""") 2600CLOSE #handle2% 2610ENDPROC 2620: 2630DEFPROCcallwp 2640PROCcursor(1) 2650PRINT '"Making corrections - Please wait .. "; 2660*FX 3 2 2670*FX 21 0 2680FOR loop%=1 TO 13 2690OSCLI("FX 138 0 "+STR$(ASC(MID$("*E XEC CORRECT",loop%,1)))) 2700NEXT 2710*FX 138 0 13 2720END 2730: 2740DEFPROCchangedict 2750PROCsavedict 2760PROCloaddict(letter%) 2770oldletter%=letter% 2780ENDPROC 2790: 2800DEFPROCloaddict(letter%) 2810A%=3 2820fileptr%=index%!(letter%*8) 2830dictsize%=index%!((letter%+1)*8)-fi leptr% 2840dictlen%=index%!(letter%*8+4) 2850dicttop%=dictbuf%+dictlen% 2860PROCgbpb(A%,handle%,dictbuf%,dictsi ze%,fileptr%) 2870ENDPROC 2880: 2890DEFPROCsavedict 2900IF oldletter%=-1 ENDPROC 2910A%=1 2920PROCgbpb(A%,handle%,dictbuf%,dictsi ze%,fileptr%) 2930ENDPROC 2940: 2950DEFPROCasm 2960DIM code% &B0 2970source%=&70 2980dest%=&72 2990len%=&74 3000buffptr%=&70 3010buffend%=&74 3020searchptr%=&76 3030result%=&78 3040temp%=&78 3050FOR pass = 0 TO 2 STEP 2 3060P%=code% 3070[ 3080OPT pass 3090.move 3100½-------- 3110SEC 3120LDA dest% 3130SBC source% 3140TAX 3150LDA dest%+1 3160SBC source%+1 3170TAY 3180TXA 3190CMP len% 3200TYA 3210SBC len%+1 3220BCS moveleft 3230BCC moveright 3240.moveleft 3250LDY #0 3260LDX len%+1 3270BEQ mlskip 3280.mlloop 3290LDA (source%),Y 3300STA (dest%),Y 3310INY 3320BNE mlloop 3330INC source%+1 3340INC dest%+1 3350DEX 3360BNE mlloop 3370.mlskip 3380LDX len% 3390BEQ moveout 3400.mlloop2 3410LDA (source%),Y 3420STA (dest%),Y 3430INY 3440DEX 3450BNE mlloop2 3460.moveout 3470RTS 3480 3490.moveright 3500CLC 3510LDA len%+1 3520PHA 3530ADC source%+1 3540STA source%+1 3550CLC 3560PLA 3570ADC dest%+1 3580STA dest%+1 3590LDY len% 3600BEQ mrskip 3610.mrloop 3620DEY 3630LDA (source%),Y 3640STA (dest%),Y 3650CPY #0 3660BNE mrloop 3670.mrskip 3680LDX len%+1 3690BEQ moveout 3700.mrloop2 3710DEC source%+1 3720DEC dest%+1 3730.mrloop3 3740DEY 3750LDA (source%),Y 3760STA (dest%),Y 3770CPY #0 3780BNE mrloop3 3790DEX 3800BNE mrloop2 3810RTS 3820½ 3830.search 3840LDY #255 3850.sloop 3860INY 3870LDA (buffptr%),Y 3880CMP #13 3890BEQ foundword 3900CMP (searchptr%),Y 3910BEQ sloop 3920BCC nextword 3930.notfound 3940LDY #0 3950STY result% 3960RTS 3970.foundword 3980LDA (searchptr%),Y 3990CMP #13 4000BNE incptr 4010LDY #1 4020STY result% 4030RTS 4040.nextword 4050INY 4060LDA (buffptr%),Y 4070CMP #13 4080BNE nextword 4090.incptr 4100INY 4110STY temp% 4120LDY #255 4130CLC 4140LDA buffptr% 4150ADC temp% 4160STA buffptr% 4170LDA buffptr%+1 4180ADC #0 4190STA buffptr%+1 4200CMP buffend%+1 4210BCC sloop 4220LDA buffptr% 4230CMP buffend% 4240BCC sloop 4250JMP notfound 4260] 4270NEXT 4280ENDPROC 4290: 4300DEFFNfindword(buf%,top%,word$) 4310IF buf%=top% !buffptr%=buf%:=0 4320!buffptr%=buf% 4330!buffend%=top% 4340!searchptr%=wordbuf% 4350$wordbuf%=word$ 4360CALL search 4370=?result% 4380: 4390DEFFNgetkey 4400LOCAL key% 4410PROCcursor(1) 4420*FX 21 0 4430key%=GET 4440PROCcursor(0) 4450=CHR$(key% AND 223) 4460: 4470DEFPROCcursor(on%) 4480VDU 23,1,on%;0;0;0; 4490ENDPROC 4500: 4510DEFPROCgbpb(A%,handle%,address%,siz e%,fileptr%) 4520X%=block% MOD 256 4530Y%=block% DIV 256 4540block%?0=handle% 4550block%!1=address% 4560block%!5=size% 4570block%!9=fileptr% 4580CALL osgbpb 4590ENDPROC 4600: 4610DEFPROCoscli 4620PROCcursor(1) 4630CLS 4640PRINT "Press RETURN to go back to S PELLCHECK"' 4650REPEAT 4660INPUT LINE '"*"command$ 4670OSCLI(command$) 4680UNTIL command$="" 4690PROCcursor(0) 4700ENDPROC 4710: 4720DEFPROCerror 4730PROCcursor(1) 4740CLOSE #0 4750IF ERR=17 CLS:END 4760PRINT ''' 4770REPORT 4780PRINT " at line ";ERL 4790PRINT ' 4800ENDPROC