0MODE7
10 *TV255,1
20 PROCoff
30 CLS: REM Rekenstructie
40 PROCmeasure : REM scherm opmeten
50 PROCtitel : REM beginscherm
60 PROCinit : REM init / uitleg
70 PROCdigit : REM aantal cijfers
80 PROCquestion : REM bepaal opgave
90 PROCanswer : REM invoer
100 PROCcheck : REM controle
110 PROCcorrect : REM tweede poging
120 PROCagain : REM nogmaals
130 IF Q=1 THEN 70
140 PROCresult : REM resultaat
150 PROCon:END
160 :
170 DEFPROCdigit : REM aantal cijfers
180 PRINT:PRINT S$;K$:HO=S:VE=22:PRINT
TAB(HO,VE);
190 PRINT K$;:VE=3:PRINTTAB(HO,VE);
200 PRINT " Get ready. Here's a pu
zzle...."
210 PRINT
220 PRINT S$;"How large will it be ?
2..t/m..8 ";
230 PROCkey:L=(ASC(IN$)-ASC("0"))
240 IF (L<2) OR (L>8) THEN 230
250 HO=S+5:VE=8:PRINTTAB(HO,VE);:PRINT
"uno momento..."
260 PRINT:PZ$(L)="":ENDPROC
270 :
280 DEFPROCquestion : REM opgave bepal
en
290 HO=S:VE=10:PRINTTAB(HO,VE);:PRINT
K$;
300 VE=14:PRINTTAB(HO,VE);:PRINT K$;
310 P=0:FOR I=1 TO L
320 RV=RND(1):C(I)=INT(RV*10):IF C(I)<
1 THEN 320
330 SR=C(I):SR$=STR$SR:C$(I)=SR$:NEXT
I
340 FOR I=1 TO L-1:PROCsign:NEXT I
350 FOR I=1 TO L-1:R$(I)=PZ$(I):NEXT I
360 PROCcalc
370 IF (SR<-9999) OR (SR>9999) THEN 31
0
380 IF MF=1 THEN 410
390 IF (MF=2) AND (SR<0) THEN 310
400 IF (MF>2) AND (Q<>0) THEN 310
410 B$="":FOR I=1 TO L:B$=B$+C$(I)+PZ$
(I):NEXT I
420 UK=SR:SR$=STR$SR:PZ$(L)=" = "+SR$
430 HO=S:VE=5:PRINTTAB(HO,VE);:PRINT S
P$
440 PRINT S$;T$
450 SR=L:SR$=STR$SR:PRINT
460 PRINT S$;"Level ";MF$;".";
470 PRINT " The ";SR$;" numbers are
:"
480 HO=S+1:VE=12:PRINTTAB(HO,VE);
490 FOR I=1 TO L-1:PRINT C$(I);" ";:
NEXT I
500 PRINT C$(L);PZ$(L)
510 ENDPROC
520 :
530 DEFPROCsign : REM keuze operator
540 RV=RND(1):RT=INT(RV*10)
550 IF (RT<1) OR (RT>NV) THEN 540
560 ON RT GOTO 570,580,590,610
570 PZ$(I)="+":ENDPROC
580 PZ$(I)="-":ENDPROC
590 PZ$(I)="*":IF PZ$(I-1)="/" THEN 54
0
600 ENDPROC
610 PZ$(I)="/":DL=C(I)/C(I+1)
620 IF (INT(DL)<>DL) OR (PZ$(I-1)="/")
THEN 540
630 ENDPROC
640 :
650 DEFPROCanswer : REM invoer antwoor
d
660 X=1:HO=S+3:VE=12:PRINTTAB(HO,VE);
670 :
680 DEFPROCanswer2
690 PROCon:FOR I=X TO L
700 IF I=L THEN PROCoff:PROCready
710 PROCkey:AW=ASC(IN$):VB=0:PROCon
720 IF (IN$="P") OR (IN$="p") THEN IN$
="+"
730 IF (IN$="M") OR (IN$="m") THEN IN$
="-"
740 IF (IN$="X") OR (IN$="x") THEN IN$
="*"
750 IF (IN$="D") OR (IN$="d") THEN IN$
="/"
760 IF (IN$="C") OR (IN$="c") THEN VB=
1
770 IF (IN$="*") AND (NV<3) THEN 710
780 IF (IN$="/") AND (NV<4) THEN 710
790 IF (AW=13) AND (I=L) THEN 850
800 IF (I=L) AND (VB=0) THEN 710
810 IF (VB=1) AND (I>X) THEN PROCcurba
ck
820 IF (IN$="+") OR (IN$="-") THEN 840
830 IF (IN$<>"*") AND (IN$<>"/") THEN
710
840 PROCcurforw
850 NEXT I
860 HO=S:VE=16:PRINTTAB(HO,VE);:PRINT
SP$
870 PROCoff:ENDPROC
880 :
890 DEFPROCready : REM invoer klaar
900 H1=HO:V1=VE:HO=S:VE=16:PRINTTAB(HO
,VE);
910 PRINT "RETURN to go on, C to corre
ct..."
920 HO=H1:VE=V1:PRINTTAB(HO,VE);
930 ENDPROC
940 :
950 DEFPROCcurforw : REM cursor plaats
verder
960 AW$(I)=IN$:PRINT IN$;
970 IF P=1 THEN PROCcurforw2
980 HO=S+3+(I*4):VE=12:PRINTTAB(HO,VE)
;
990 ENDPROC
1000 :
1010 DEFPROCcurback : REM cursor plaats
terug
1020 IF I<>L THEN 1040
1030 HO=S:VE=16:PRINTTAB(HO,VE);:PRINT
SP$
1040 IF P=1 THEN PROCcurback2:ENDPROC
1050 HO=S+3+(I-2)*4:H1=HO:VE=12:PRINTTA
B(HO,VE);
1060 PRINT " ";:AW$(I)="":I=I-1
1070 HO=H1:VE=12:PRINTTAB(HO,VE);
1080 ENDPROC
1090 :
1100 DEFPROCcurforw2 : REM cursor plaat
s poging 2
1110 FOR J=I+1 TO L-1
1120 IF AW(J)=0 THEN I=J-1:J=L-1
1130 NEXT J
1140 ENDPROC
1150 :
1160 DEFPROCcurback2 : REM cursor terug
poging 2
1170 IF I<>L THEN 1190
1180 HO=S:PRINTTAB(HO,VE);:PRINT "Secon
d try.... "
1190 Y=0:FOR J=I-1 TO X STEP -1
1200 IF AW(J)=0 THEN Y=Y+1:I=J:J=X
1210 NEXT J:IF Y=0 THEN 1240
1220 HO=S+3+(I-1)*4:H1=HO:VE=12:PRINTTA
B(HO,VE);
1230 PRINT " ";:AW$(I)="":HO=H1:PRINTTA
B(HO,VE);
1240 ENDPROC
1250 :
1260 DEFPROCcheck : REM controle
1270 FOR I=1 TO L-1:R$(I)=AW$(I):NEXT I
1280 PROCcalc:AC=SR
1290 HO=S:VE=16:PRINTTAB(HO,VE);
1300 IF UK=AC THEN 1350
1310 PRINT "Alas... no good."
1320 P=P+1:IF P=1 THEN ENDPROC
1330 VE=18:PRINTTAB(HO,VE);:PRINT "It s
hould be... ";B$
1340 ENDPROC
1350 W$="SUPER":IF P=1 THEN W$="GREAT"
1360 HO=S+12:VE=18:FOR I=1 TO 3
1370 PRINTTAB(HO,VE);:PRINT W$;" CLASSs
"
1380 FOR J=1 TO 4*VT:NEXT J
1390 PRINTTAB(HO,VE);:PRINT "
"
1400 FOR J=1 TO 4*VT:NEXT J
1410 NEXT I
1420 ENDPROC
1430 :
1440 DEFPROCcorrect : REM tweede poging
1450 IF P<>1 THEN ENDPROC
1460 FOR I=1 TO 50*VT:NEXT I
1470 FOR I=1 TO L-1:AW(I)=1
1480 IF (PZ$(I)=AW$(I)) AND (MF<4) THEN
1510
1490 AW(I)=0:VE=12:HO=S+3+(I-1)*4
1500 PRINTTAB(HO,VE);: PRINT " ";
1510 NEXT I
1520 HO=S:VE=16:PRINTTAB(HO,VE);
1530 PRINT "Second try.... "
1540 FOR I=1 TO L-1
1550 IF AW(I)=1 THEN 1580
1560 VE=12:HO=S+3+(I-1)*4
1570 PRINTTAB(HO,VE);:X=I:I=L-1
1580 NEXT I
1590 L1=-1:FOR I=L-1 TO 1 STEP -1
1600 IF AW(I)=1 THEN 1620
1610 I=1
1620 L1=L1+1:NEXT I
1630 L=L-L1:PROCanswer2
1640 L=L+L1:PROCcheck
1650 ENDPROC
1660 :
1670 DEFPROCagain : REM nog een keer
1680 T(L,P)=T(L,P)+1
1690 HO=S+4:VE=20:PRINTTAB(HO,VE);:Q=0
1700 PRINT "Another one ? Y/n ";
1710 PROCkey:X=ASC(IN$)
1720 IF (X=13) OR (IN$="Y") OR (IN$="y"
) THEN Q=1
1730 IF (IN$="N") OR (IN$="n") THEN Q=2
1740 IF Q=0 THEN 1710
1750 IF Q=1 THEN T=T+1
1760 CLS:ENDPROC
1770 :
1780 DEFPROCcalc : REM reken
1790 FOR I=1 TO L:R(I)=C(I):NEXT I
1800 FOR I=1 TO L-1
1810 IF (R$(I)="+") OR (R$(I)="-") THEN
1850
1820 IF R$(I)="*" THEN R(I+1)=R(I)*R(I+
1)
1830 IF R$(I)="/" THEN R(I+1)=R(I)/R(I+
1)
1840 R(I)=0:R$(I)="+":IF I>1 THEN R$(I)
=R$(I-1)
1850 NEXT I:Q=0
1860 SR=R(1):FOR I=1 TO L-1
1870 IF R$(I)="+" THEN SR=SR+R(I+1)
1880 IF R$(I)="-" THEN SR=SR-R(I+1)
1890 IF SR<0 THEN Q=Q+1
1900 NEXT I
1910 ENDPROC
1920 :
1930 DEFPROCresult : REM resultaat
1940 Y=0:VT=INT(VT/4):SR=T:SR$=STR$SR
1950 R$(1)="MARVELLOUS.... all's well
done."
1960 R$(2)="Sorry.... better next ti
me."
1970 B$="sums":IF T=1 THEN B$="sum"
1980 C$(1)="You made "+SR$+" puzzle "+B
$+"."
1990 C$(2)="Level "+MF$+". 1x
2x wrong"
2000 FOR C=2 TO 8:B$="":SR=C:SR$=STR$SR
2010 C$(C+1)=SR$+" numbers "
2020 FOR R=0 TO 2:SR=T(C,R):SR$=STR$SR
2030 IF SR$="0" THEN SR$=" "
2040 B$=B$+LEFT$(SP$,7-LEN(SR$))+SR$
2050 NEXT R:C$(C+1)=C$(C+1)+B$
2060 NEXT C:X=0
2070 FOR I=2 TO 8:X=X+T(I,2):NEXT I
2080 IF (X=0) OR (X=T) THEN 2120
2090 Q=T-X:SR=Q:SR$=STR$SR
2100 B$="You have "+SR$+" good and alas
"
2110 SR=X:SR$=STR$SR:C$(10)=B$+SR$+" wr
ong."
2120 IF X=0 THEN C$(10)=R$(1)
2130 IF X=T THEN C$(10)=R$(2)
2140 HO=S:X=2
2150 FOR C=1 TO 10:X=X+1
2160 IF (C=2) OR (C=3) THEN X=X+1
2170 IF C=10 THEN X=X+2
2180 VE=X:B$=C$(C):PROCtext
2190 NEXT C
2200 B$="Print the result ? Y/n "
2210 HO=S+3:VE=18:PROCtext
2220 PROCkey:X=ASC(IN$)
2230 IF (IN$="N") OR (IN$="n") THEN 233
0
2240 IF (X<>13) AND (IN$<>"Y") AND (IN$
<>"y") THEN 2220
2250 PROCempty:B$="Printer ready ? k
ey.."
2260 PROCtext:PROCkey:PROCempty
2270 PRINTTAB(HO,VE);:PRINT " Printing
. ";
2280 FOR I=1 TO 10
2290 IF (I=2) OR (I=3) THEN PROCprlf
2300 IF I=10 THEN PROCprlf:PROCprlf
2310 SR$=" "+C$(I):PROCprline:PROCp
rlf
2320 NEXT I:FOR I=1 TO 6:PROCprlf:NEXT
I
2330 PROCempty:B$="Till next time."
2340 PROCtext
2350 PRINT:PRINT
2360 ENDPROC
2370 :
2380 DEFPROCempty : REM regel leeg
2390 HO=S:PRINTTAB(HO,VE);:PRINT SP$
2400 HO=S+3:ENDPROC
2410 :
2420 DEFPROCkey : REM Buffer legen + To
ets lezen
2430 IN$=INKEY$0:IF IN$<>"" THEN 2430
2440 IN$=GET$:ENDPROC
2450 :
2460 DEFPROCmeasure : REM Scherm opmete
n
2470 VE=0:FOR I=0 TO 150
2480 PRINT "*";:HO=POS:VE=VPOS
2490 PH=I:IF VE<>0 THEN I=150
2500 NEXT I:CLS
2510 S$=" ":IF PH<=39 THEN 2540
2520 X=INT((PH-39)/2)
2530 FOR I=2 TO X:S$=S$+" ":NEXT I
2540 S=LEN(S$):PROCdelay
2550 ENDPROC
2560 :
2570 DEFPROCtitel : REM beginscherm
2580 K$="MISSING signs "
2590 R$="":X=INT(PH/LEN(K$))+1
2600 FOR I=1 TO X:R$=R$+K$:NEXT I
2610 FOR I=1 TO 22:HO=I+1:VE=I:PRINTTAB
(HO,VE);
2620 PRINT LEFT$(R$,PH-I-1):NEXT I:Y=0
2630 HO=0:VE=17:B$=" A":PROCtext
2640 VE=18:B$=" program":PROCtext
2650 VE=19:B$=" by L.Looyenga":PROCtext
2660 ENDPROC
2670 :
2680 DEFPROCinit : REM Init + uitleg
2690 DIM C(8),R(8),AW(8),C$(10),PZ$(8),
AW$(8),R$(8)
2700 DIM T(8,2):T=1:PZ$(0)="":K$="":SP$
=""
2710 FOR I=1 TO 38:K$=K$+"*":SP$=SP$+"
":NEXT I
2720 VE=22:B$=" Explanation ? Y/n ":PRO
Ctext
2730 PROCkey:X=ASC(IN$)
2740 IF (IN$="N") OR (IN$="n") THEN 349
0
2750 IF (X<>13) AND (IN$<>"Y") AND (IN$
<>"y") THEN 2730
2760 :
2770 CLS
2780 PRINT S$;" Figure it out!"
2790 PRINT
2800 PRINT S$;"The computer prints a su
m on the screen"
2810 PRINT S$;"but...the signs + - * or
/ are missing."
2820 PRINT
2830 PRINT S$;" You must complet
e it."
2840 PRINT
2850 PRINT
2860 PRINT S$;"Look, between the digits
, you can use.."
2870 PRINT
2880 PRINT S$;" + or P for Plus."
2890 PRINT S$;" - or M for Minus.
"
2900 PRINT S$;" * or X for Multip
ly."
2910 PRINT S$;" / or D for Divide
."
2920 PRINT
2930 PRINT S$;" And the C key for Corr
ection."
2940 PRINT
2950 PRINT S$;"You get two tries to sol
ve the puzzle."
2960 PRINT S$;"At second try all good s
igns stay."
2970 PRINT S$;"(but NOT at level 4)"
2980 PRINT
2990 PRINT S$;" Now a key for the cont
inuing, ";
3000 PROCkey
3010 :
3020 CLS:PRINT:PRINT
3030 PRINT S$;" **** !IMPORTANT!
****":PRINT
3040 PRINT S$;"X and / go BEFORE plus
and minus !!! ";
3050 PROCpause:PROCpause:Y=1
3060 HO=S:VE=6:B$="Look at this example
...."
3070 PROCtext:PROCpause
3080 HO=S+20:VE=8:B$="7+5*6-9/3 ="
3090 PROCtext
3100 HO=S:VE=10:B$="First"
3110 PROCtext
3120 A$="5":HO=S+22:VE=8:X=1:PROCdown
3130 A$="*":HO=S+23:VE=8:PROCdown
3140 A$="6":HO=S+24:VE=8:PROCdown
3150 PROCpause
3160 HO=S+30:VE=10:B$="=30"
3170 PROCtext
3180 HO=S:VE=11:B$="Then"
3190 PROCtext
3200 A$="9":HO=S+26:VE=8:X=2:PROCdown
3210 A$="/":HO=S+27:VE=8:PROCdown
3220 A$="3":HO=S+28:VE=8:PROCdown
3230 PROCpause
3240 HO=S+30:VE=11:B$="= 3"
3250 PROCtext
3260 HO=S:VE=13:B$="Complete it now..."
3270 PROCtext
3280 A$="7":HO=S+20:VE=8:X=4:PROCdown
3290 A$="+":HO=S+21:VE=8:PROCdown
3300 PROCpause
3310 HO=S+31:VE=10:PRINTTAB(HO,VE);:PRI
NT " 30"
3320 A$="30":HO=S+33:VE=9:X=3:PROCdown
3330 VE=13:X=10:PROCleft
3340 PROCpause
3350 A$="-":HO=S+25:VE=8:X=4:PROCdown
3360 PROCpause
3370 A$=" 3":HO=S+31:VE=10:X=2:PROCdown
3380 VE=13:X=5:PROCleft
3390 PROCpause
3400 HO=S+30:B$="=34"
3410 PROCtext:PRINT:PRINT:PRINT
3420 PRINT S$;"When you think you solve
d the puzzle"
3430 PRINT S$;"right, then press <RETU
RN> and..."
3440 PRINT S$;"you will discover if all
IS right."
3450 PRINT:PRINT
3460 PRINT S$;" Now any key, for the be
ginning. ";
3470 PROCkey
3480 :
3490 CLS:PRINT:PRINT
3500 PRINT S$;" Levels of difficu
lty."
3510 PRINT:PRINT
3520 PRINT S$;" There are four leve
ls..."
3530 PRINT:PRINT
3540 PRINT S$;" 4 - only plus and mi
nus."
3550 PRINT
3560 PRINT S$;" 3 - and multiplicati
on."
3570 PRINT
3580 PRINT S$;" 2 - divisions too an
d could give"
3590 PRINT S$;" negative operati
on in between."
3600 PRINT
3610 PRINT S$;" 1 - run the risk of
a positive"
3620 PRINT S$;" or negative end
result."
3630 HO=S:VE=21:PRINTTAB(HO,VE);:PRINT
SP$;
3640 MF=4:HO=S+6:VE=19:PRINTTAB(HO,VE);
:PRINT SP$:PRINTTAB(HO,VE);
3650 PRINT "Which number do you want ";
3660 INPUT B$:PRINT:IF (B$="") OR (B$="
4") THEN 3730
3670 MF=VAL(B$):IF (MF<1) OR (MF>4) THE
N 3640
3680 IF (MF=3) OR (MF=4) THEN 3730
3690 PRINT S$;" Really the most difficu
lt ones ? Y/n ";
3700 PROCkey:X=ASC(IN$)
3710 IF (IN$="N") OR (IN$="n") THEN 363
0
3720 IF (X<>13) AND (IN$<>"Y") AND (IN$
<>"y") THEN 3700
3730 NV=6-MF:IF NV=5 THEN NV=4
3740 SR=MF:SR$=STR$SR:MF$=SR$:CLS
3750 ON NV-1 GOSUB 3780,3790,3800
3760 ENDPROC
3770 :
3780 T$=" Find the plus and minus sign
s":RETURN
3790 T$="Thinking.... first X then +
and -":RETURN
3800 T$="Remember.... X and / go befor
e + en -":RETURN
3810 :
3820 DEFPROCtext : REM plaats tekst
3830 PRINTTAB(HO,VE);
3840 FOR I=1 TO LEN(B$)
3850 FOR J=1 TO VT:NEXT J
3860 PRINT MID$(B$,I,1);
3870 NEXT I
3880 IF Y=1 THEN PROCpause
3890 ENDPROC
3900 :
3910 DEFPROCdown : REM beweging omlaag
3920 S1$=LEFT$(SP$,LEN(A$))
3930 FOR I=1 TO X:VE=VE+1
3940 FOR J=1 TO VT:NEXT J
3950 PRINTTAB(HO,VE);:PRINT A$;
3960 FOR J=1 TO VT:NEXT J
3970 VE=VE+1:PRINTTAB(HO,VE);:PRINT A$;
3980 VE=VE-1:PRINTTAB(HO,VE);:PRINT S1$
;
3990 NEXT I
4000 ENDPROC
4010 :
4020 DEFPROCleft : REM beweging links
4030 FOR I=X TO 1 STEP -1:HO=HO-1
4040 FOR J=1 TO VT:NEXT J
4050 PRINTTAB(HO,VE);:PRINT A$;
4060 FOR J=1 TO VT:NEXT J
4070 HO=HO+2:PRINTTAB(HO,VE);:PRINT S1$
;
4080 HO=HO-2:NEXT I
4090 ENDPROC
4100 :
4110 DEFPROCprline :REM print string
4120 *FX3,10
4130 PRINTSR$;:*FX3
4140 ENDPROC
4150 :
4160 DEFPROCprlf : REM print lf
4170 *FX3,10
4180 PRINT:*FX3
4190 ENDPROC
4200 :
4210 DEFPROCpause : REM pauze
4220 FOR I=1 TO 20*VT:NEXT I
4230 ENDPROC
4240 :
4250 DEFPROCdelay:VT=50:ENDPROC
4260 :
4270 DEFPROCon:VDU 23,1,1;0;0;0;:ENDPRO
C
4280 DEFPROCoff:VDU 23,1,0;0;0;0;:ENDPR
OC
4290 :
4300 REM You can change speed in
4310 REM some parts of the program
4320 REM by altering the value of
4330 REM VT at line 4250
4340 REM
4350 REM Program written by:
4360 REM L.Looyenga
4370 REM januari 1990 / may 1997
4380 REM Program translated by:
4390 REM Janny Looyenga
4400 REM may 1997