8-Bit Software Online Conversion

Wordsearch Solver 2 - Listing

10REM Word Puzzle Solver V.2.5 20REM by M.Bobrowski for 8BS 30: 40MODE 4:VDU 19,0,4;0;19,1,3;0; 50PROCinit 60PROCenterpuzzle 70PROCscreen 80REPEAT:VDU 28,1,31,38,26 90REPEAT:CLS:VDU 23,1,1;0;0;0; 100INPUT"Enter hidden word : "W$ 110W$=FNcase(W$):L%=LENW$:UNTIL ok AND L%>0:VDU 23,1,0;0;0;0; 120PROCsearch:IF found PRINT'"Start po int - ";CHR$(H%+64);V%;". The word is pl aced"'T$(D%);".":REPEAT:PROCshow(H%,V%,0 ):PROCshow(H%,V%,1):UNTILINKEY-99 130UNTIL FALSE 140: 150DEF PROCinit 160MOVE 320,1000:DRAW 956,1000:MOVE 32 0,992:DRAW 956,992:COLOUR0:COLOUR129:PRI NTTAB(10,1)" WORD PUZZLE SOLVER ":COLOUR 1:COLOUR128:MOVE 320,952:DRAW 956,952 170REPEAT:PRINTTAB(1,3)SPC38:INPUTTAB( 1,3)"Enter number of columns (max.26) : "M%:UNTIL M%>0 AND M%<27 180REPEAT:PRINTTAB(1,5)SPC38:INPUTTAB( 1,5)"Enter number of rows (max.20) : "N%:UNTIL N%>0 AND N%<21 190DIM L$(M%,N%),D%(7,1),T$(7) 200FOR J%=0 TO 7:READ D%(J%,0),D%(J%,1 ),T$(J%):NEXT 210B%=19-M%/2:W%=12-N%/2:A$=STRING$(K% ,"*"):C$="ABCDEFGHIJKLMNOPQRSTUVWXYZ" 220ENDPROC 230: 240DATA 1,0,horizontally,1,1,diagonall y (downwards and rightwards),0,1,downwar ds,-1,1,diagonally (downwards and leftwa rds),-1,0,backwards,-1,-1,diagonally (up wards and leftwards),0,-1,upwards,1,-1,d iagonally (upwards and rightwards) 250: 260DEF PROCenterpuzzle 270PRINT'" Now enter the puzzle, row b y row ....":PRINT 280FOR R%=1 TO N% 290v%=VPOS:REPEAT:PRINTTAB(2,v%)"row " ;RIGHT$(" "+STR$R%,2);" : ";STRING$(M%, ".");SPC(39-POS);:INPUTTAB(11,v%)R$:R$=F Ncase(R$):IF LENR$<>M% VDU7 300UNTIL ok=TRUE AND LENR$=M% 310FOR C%=1 TO M% 320L$(C%,R%)=MID$(R$,C%,1) 330NEXT:NEXT 340ENDPROC 350: 360DEF PROCscreen 370CLS:MOVE 32*B%-16,1040-32*W%:DRAW 3 2*(B%+M%)+16,1040-32*W%:DRAW 32*(B%+M%)+ 16,1040-32*(W%+N%+1):DRAW 32*B%-16,1040- 32*(W%+N%+1):DRAW 32*B%-16,1040-32*W% 380FOR R%=1 TO N%:PRINTTAB(B%-3,R%+W%- 1);RIGHT$(" "+STR$R%,2);CHR$9; 390FOR C%=1 TO M%:PRINT L$(C%,R%); 400NEXT:NEXT:PRINT''TAB(B%)LEFT$(C$,M% )TAB(0,25)STRING$(40,"-") 410ENDPROC 420: 430DEF PROCsearch:found=FALSE 440PROChorizontal:IF found ENDPROC 450PROCbackwards:IF found ENDPROC 460PROCdownwards:IF found ENDPROC 470PROCupwards:IF found ENDPROC 480PROCdownright:IF found ENDPROC 490PROCdownleft:IF found ENDPROC 500PROCupleft:IF found ENDPROC 510PROCupright:IF found ENDPROC 520IF NOT found VDU7:PRINT'"Word not f ound."''"Press SPACE to continue";:REPEA T UNTIL GET=32 530ENDPROC 540: 550DEF PROChorizontal 560D%=0:FOR R%=1 TO N% 570A$="" 580FOR C%=1 TO M% 590A$=A$+L$(C%,R%):I%=INSTR(A$,W$) 600IF I%>0 H%=I%:V%=R%:R%=N%:C%=M%:fou nd=TRUE 610NEXT:NEXT 620ENDPROC 630: 640DEF PROCbackwards 650D%=4:FOR R%=1 TO N% 660A$="" 670FOR C%=M% TO 1 STEP -1 680A$=A$+L$(C%,R%):I%=INSTR(A$,W$) 690IF I%>0 H%=M%-I%+1:V%=R%:R%=N%:C%=1 :found=TRUE 700NEXT:NEXT 710ENDPROC 720: 730DEF PROCdownwards 740D%=2:FOR C%=1 TO M% 750A$="" 760FOR R%=1 TO N% 770A$=A$+L$(C%,R%):I%=INSTR(A$,W$) 780IF I%>0 H%=C%:V%=I%:R%=N%:C%=M%:fou nd=TRUE 790NEXT:NEXT 800ENDPROC 810: 820DEF PROCupwards 830D%=6:FOR C%=1 TO M% 840A$="" 850FOR R%=N% TO 1 STEP -1 860A$=A$+L$(C%,R%):I%=INSTR(A$,W$) 870IF I%>0 H%=C%:V%=N%-I%+1:R%=1:C%=M% :found=TRUE 880NEXT:NEXT 890ENDPROC 900: 910DEF PROCdownright 920D%=1:FOR R%=1 TO N% 930FOR C%=1 TO M% 940A$="":X%=C%:Y%=R% 950REPEAT:A$=A$+L$(X%,Y%):I%=INSTR(A$, W$):IF I%>0 found=TRUE 960X%=X%+1:Y%=Y%+1 970UNTIL X%>M% OR Y%>N% OR found:IF fo und H%=X%-L%:V%=Y%-L%:C%=M%:R%=N% 980NEXT:NEXT 990ENDPROC 1000: 1010DEF PROCdownleft 1020D%=3:FOR R%=1 TO N% 1030FOR C%=M% TO 1 STEP -1 1040A$="":X%=C%:Y%=R% 1050REPEAT:A$=A$+L$(X%,Y%):I%=INSTR(A$, W$):IF I%>0 found=TRUE 1060X%=X%-1:Y%=Y%+1 1070UNTIL X%<1 OR Y%>N% OR found:IF fou nd H%=X%+L%:V%=Y%-L%:C%=1:R%=N% 1080NEXT:NEXT 1090ENDPROC 1100: 1110DEF PROCupleft 1120D%=5:FOR R%=N% TO 1 STEP -1 1130FOR C%=M% TO 1 STEP -1 1140A$="":X%=C%:Y%=R% 1150REPEAT:A$=A$+L$(X%,Y%):I%=INSTR(A$, W$):IF I%>0 found=TRUE 1160X%=X%-1:Y%=Y%-1 1170UNTIL X%<1 OR Y%<1 OR found:IF foun d H%=X%+L%:V%=Y%+L%:C%=1:R%=1 1180NEXT:NEXT 1190ENDPROC 1200: 1210DEF PROCupright 1220D%=7:FOR R%=N% TO 1 STEP -1 1230FOR C%=1 TO M% 1240A$="":X%=C%:Y%=R% 1250REPEAT:A$=A$+L$(X%,Y%):I%=INSTR(A$, W$):IF I%>0 found=TRUE 1260X%=X%+1:Y%=Y%-1 1270UNTIL X%>M% OR Y%<1 OR found:IF fou nd H%=X%-L%:V%=Y%+L%:C%=M%:R%=1 1280NEXT:NEXT 1290ENDPROC 1300: 1310DEF PROCshow(X%,Y%,K%) 1320VDU26:COLOUR K%:COLOUR129-(K%=1) 1330FOR J%=1 TO LEN W$ 1340PRINTTAB(X%+B%-1,Y%+W%-1)MID$(W$,J% ,1) 1350X%=X%+D%(D%,0):Y%=Y%+D%(D%,1) 1360NEXT:IF K%=1 XX=INKEY(100) ELSE XX= INKEY(10) 1370IF K%=1 PRINTTAB(1,31)"Press SPACE to continue"; 1380ENDPROC 1390: 1400DEF FNcase(C$) 1410LOCAL Z%,B$:B$="" 1420FOR J%=1 TO LENC$ 1430Z%=ASCMID$(C$,J%,1):IF Z%>64 AND Z% <91 OR Z%>96 AND Z%<123 ok=TRUE ELSE ok= FALSE:J%=LENC$:NEXT:VDU7:="" 1440IF Z%>64 AND Z%<91 B$=B$+CHR$(Z%+32 ) ELSE B$=B$+CHR$Z% 1450NEXT 1460=B$