8-Bit Software Online Conversion
Wordsearch Solver 1 - Listing
10REM Word Square Solver V.2.0
20REM by M.Bobrowski for 8BS
30:
40MODE 129
50INPUT'"Enter number of columns : "M
%
60INPUT'"Enter number of rows : "N
%
70IF M%>=N% K%=M% ELSE K%=N%
80DIM L$(K%,K%),D%(7,1)
90FOR J%=0 TO 7:READ D%(J%,0),D%(J%,1
):NEXT
100B%=19-M%/2:A$=STRING$(K%,"*")
110FOR R%=1 TO N%
120PRINT'"Enter ";RIGHT$(" "+STR$R%,2
);" row : ";:INPUT""R$
130FOR C%=1 TO M%
140L$(C%,R%)=MID$(R$,C%,1)
150NEXT:NEXT
160CLS:PRINTTAB(B%)STRING$(M%,"-"):COL
OUR 2:FOR R%=1 TO N%
170PRINTTAB(B%);
180FOR C%=1 TO M%
190PRINT L$(C%,R%);
200NEXT:NEXT:COLOUR3:PRINT'TAB(B%)STRI
NG$(M%,"-")TAB(0,25)STRING$(40,"-");
210REPEAT:VDU 28,0,31,39,26,12:COLOUR3
:INPUT"Enter hidden word : "W$:L%=LENW$:
IF W$="" END
220PROCsearch:IF F% PRINT"Word starts
from point (";H%;",";V%;")":PROCdisplay(
H%,V%,1):PROCdisplay(H%,V%,2)
230UNTIL FALSE
250:
260DEF PROCsearch:F%=FALSE
270PROChorizontal:IF F% ENDPROC
280PROCbackwards:IF F% ENDPROC
290PROCdownwards:IF F% ENDPROC
300PROCupwards:IF F% ENDPROC
310PROCdownright:IF F% ENDPROC
320PROCdownleft:IF F% ENDPROC
330PROCupleft:IF F% ENDPROC
340PROCupright:IF F% ENDPROC
350IF NOT F% PRINT"Word not found."'"P
ress SPACE to continue";:REPEAT UNTIL GE
T=32
360ENDPROC
370:
380DEF PROChorizontal
390D%=0:FOR R%=1 TO N%
400A$=""
410FOR C%=1 TO M%
420A$=A$+L$(C%,R%):I%=INSTR(A$,W$)
430IF I%>0 H%=I%:V%=R%:R%=N%:C%=M%:F%=
TRUE
440NEXT:NEXT
460ENDPROC
470:
480DEF PROCbackwards
490D%=4:FOR R%=1 TO N%
500A$=""
510FOR C%=M% TO 1 STEP -1
520A$=A$+L$(C%,R%):I%=INSTR(A$,W$)
530IF I%>0 H%=M%-I%+1:V%=R%:R%=N%:C%=1
:F%=TRUE
540NEXT:NEXT
560ENDPROC
570:
580DEF PROCdownwards
590D%=2:FOR C%=1 TO M%
600A$=""
610FOR R%=1 TO N%
620A$=A$+L$(C%,R%):I%=INSTR(A$,W$)
630IF I%>0 H%=C%:V%=I%:R%=N%:C%=M%:F%=
TRUE
640NEXT:NEXT
660ENDPROC
670:
680DEF PROCupwards
690D%=6:FOR C%=1 TO M%
700A$=""
710FOR R%=N% TO 1 STEP -1
720A$=A$+L$(C%,R%):I%=INSTR(A$,W$)
730IF I%>0 H%=C%:V%=N%-I%+1:R%=1:C%=M%
:F%=TRUE
740NEXT:NEXT
760ENDPROC
770:
780DEF PROCdownright
790D%=1:FOR R%=1 TO N%
800FOR C%=1 TO M%
810A$="":X%=C%:Y%=R%
820REPEAT:A$=A$+L$(X%,Y%):I%=INSTR(A$,
W$):IF I%>0 F%=TRUE
830X%=X%+1:Y%=Y%+1
840UNTIL X%>M% OR Y%>N% OR F%:IF F% H%
=X%-L%:V%=Y%-L%:C%=M%:R%=N%
850NEXT:NEXT
860ENDPROC
870:
880DEF PROCdownleft
890D%=3:FOR R%=1 TO N%
900FOR C%=M% TO 1 STEP -1
910A$="":X%=C%:Y%=R%
920REPEAT:A$=A$+L$(X%,Y%):I%=INSTR(A$,
W$):IF I%>0 F%=TRUE
930X%=X%-1:Y%=Y%+1
940UNTIL X%<1 OR Y%>N% OR F%:IF F% H%=
X%+L%:V%=Y%-L%:C%=1:R%=N%
950NEXT:NEXT
960ENDPROC
970:
980DEF PROCupleft
990D%=5:FOR R%=N% TO 1 STEP -1
1000FOR C%=M% TO 1 STEP -1
1010A$="":X%=C%:Y%=R%
1020REPEAT:A$=A$+L$(X%,Y%):I%=INSTR(A$,
W$):IF I%>0 F%=TRUE
1030X%=X%-1:Y%=Y%-1
1040UNTIL X%<1 OR Y%<1 OR F%:IF F% H%=X
%+L%:V%=Y%+L%:C%=1:R%=1
1050NEXT:NEXT
1060ENDPROC
1070:
1080DEF PROCupright
1090D%=7:FOR R%=N% TO 1 STEP -1
1100FOR C%=1 TO M%
1110A$="":X%=C%:Y%=R%
1120REPEAT:A$=A$+L$(X%,Y%):I%=INSTR(A$,
W$):IF I%>0 F%=TRUE
1130X%=X%+1:Y%=Y%-1
1140UNTIL X%>M% OR Y%<1 OR F%:IF F% H%=
X%-L%:V%=Y%+L%:C%=M%:R%=1
1150NEXT:NEXT
1160ENDPROC
1170:
1180DEF PROCdisplay(X%,Y%,K%)
1190VDU26:COLOUR K%:FOR J%=1 TO LEN W$
1200PRINTTAB(X%+B%-1,Y%)MID$(W$,J%,1)
1210X%=X%+D%(D%,0):Y%=Y%+D%(D%,1)
1220NEXT
1230IF K%=1 PRINTTAB(0,31)"Press SPACE
to continue";:REPEATUNTILGET
1240ENDPROC
1250:
1260DATA 1,0,1,1,0,1,-1,1,-1,0,-1,-1,0,
-1,1,-1