220 REM PROGRAM NAME=SIMLOTT (Lottery
simulation)
225 MODE 7
230 REMerror=0:ON ERROR error=ERR:PROC
error
240 PROCinitialise
250 PROCtitle
260 REPEAT
270 PROCinputdrawnnumbers
280 PROCinputseed
285 PROCwhichtoprint
290 PROCprintscreen
300 REPEAT
310 PROCgenrndnos
320 PROCtestformatches
330 PROCtestforstopping
340 UNTIL wanttostop
345 PROCsummary
350 CLS:PROCend
360 END
1000 REM```````````````````````````````
``````````````````````````````````````
1010 DEFPROCerror
1020 IF error=17 THEN PROCend:CLS:END
1030 IF error<>0 THEN REPORT:PRINT" at
line no. ";ERL
1040 PRINT''"Press RETURN to leave the
program."
1050 REPEAT:G=GET:IF G<>13 THEN VDU7
1060 UNTIL G=13
1070 PROCend
1080 END
1090 ENDPROC:REM This will never be exe
cuted.
1100 REM```````````````````````````````
``````````````````````````````````````
1110 DEFPROCinitialise:REM
INITIALISE
1120 VDU23,1,0;0;0;0;
1130 *FX11,0
1140 *FX4,1
1150 *FX202,32
1160 DIM ord$(6),wl$(6),n%(49),r%(6),r$
(6)
1170 FOR I=1 TO 6:READ ord$(I):NEXT I
1180 boards=0:np=0:m3=0:m4=0:m5=0:m5p=0
:jp=0
1190 balls$=" 1 2 3 4 5 6 7 8 910111213
1415161718192021222324252627282930313233
34353637383940414243444546474849"
1200
1210 ENDPROC
2000 REM```````````````````````````````
`````````````````````````````````````
2010 DEFPROCinput(chars$,max%,x%,y%)
2020 PRINT TAB(x%,y%)STRING$(max%,"-")
2030 ans$=""
2040 REPEAT
2050 REPEAT
2060 G$=GET$
2070 UNTIL INSTR(chars$,G$)<>0 OR ASC(G
$)=13 OR ASC(G$)=127
2080 IF INSTR(chars$,G$)<>0 AND LEN(ans
$)<max% THEN ans$=ans$+G$
2090 IF ASC(G$)=127 AND LEN(ans$)>0 THE
N ans$=LEFT$(ans$,LEN(ans$)-1)
2100 PRINT TAB(x%,y%)ans$;STRING$(max%-
LEN(ans$),"-")
2110 IF NOT seedsought THEN UNTIL ASC(G
$)=13 AND ans$<>"" ELSE UNTIL ASC(G$)=13
AND LEN(ans$)=6
2120 ENDPROC
2400 REM```````````````````````````````
`````````````````````````````````````
2410 DEFPROCend
2420 VDU23,1,1;0;0;0;
2430 *FX12,0
2440 *FX4,0
2450 *FX202,32
2460 CLOSE#0
2470 VDU26
2480 ENDPROC
2500 REM```````````````````````````````
`````````````````````````````````````
2510 DEFPROCbox(x,y,w,d,c)
2520 VDU31,x-1,y,c,188
2530 FOR I=1 TO w-2:VDU172:NEXT I:VDU23
6
2540 VDU31,x-1,y+1
2550 FOR I=1 TO d-2:VDUc,181,130,10,8,8
,8:NEXT I:VDUc,173
2560 FOR I=1 TO w-2:VDU172:NEXT I:VDU17
4
2570 VDU31,x+w-2,y+1
2580 FOR I=1 TO d-2:VDUc,234,10,8,8:NEX
T I
2590 ENDPROC
2700 REM```````````````````````````````
`````````````````````````````````````
2710 DEFPROCclear(l,b,r,t)
2720 VDU28,l,b,r,t:CLS:VDU26
2730 ENDPROC
2800 REM```````````````````````````````
`````````````````````````````````````
2810 DEFPROCtitle
2820 CLS
2830 PRINT TAB(9,1)CHR$141;CHR$133;"LOT
TERY SIMULATION";TAB(9,2)CHR$141;CHR$133
;"LOTTERY SIMULATION";
2840 PROCbox(1,3,39,21,146)
2850 PRINT TAB(2,5)CHR$135;"After the d
raw has been made, find"
2860 PRINT TAB(2,6)CHR$135;"out what yo
u would have won or lost"
2870 PRINT TAB(2,7)CHR$135;"if you'd ha
d the courage and the"
2880 PRINT TAB(2,8)CHR$135;"capital to
back your computer!"
2890 PRINT TAB(9,10)"Written specially
for";TAB(10,12)"EIGHT-BIT SOFTWARE";TAB
(12,14)"by Peter Davy."
2900 PRINT TAB(2,16)CHR$(135);"Any comm
ents or suggestions to:";TAB(2,18)CHR$13
5;"68 Headlands Road";TAB(2,19)CHR$135;"
Ossett West Yorkshire";TAB(2,20)CHR$135
;"WF5 8HX Tel. 01924 274403";
2910 PRINT TAB(11,22)"PRESS";CHR$135;"C
";CHR$130;"TO CARRY ON";
2920 REPEAT UNTIL GET$="C"
2940 ENDPROC
3000 REM```````````````````````````````
`````````````````````````````````````
3010 DEFPROCinputdrawnnumbers
3013 seedsought=FALSE
3015 REPEAT
3020 CLS
3030 PRINT TAB(0,1)CHR$130;"Please ente
r the winning set of numbers"CHR$130;"in
numerical order."
3040 FOR I=1 TO 6
3050 PRINT TAB(0,4+(I-1)*2)CHR$130;ord$
(I);" number";CHR$135
3060 PROCinput("0123456789",2,16,4+(I-1
)*2)
3070 IF LEN(ans$)=1 THEN ans$=" "+ans$:
PRINT TAB(16,4+(I-1)*2)ans$
3080 wl$(I)=ans$
3090 NEXT I
3100 PRINT TAB(0,17)CHR$133;"Bonus numb
er";CHR$135
3110 PROCinput("0123456789",2,16,17)
3120 IF LEN(ans$)=1 THEN ans$=" "+ans$:
PRINT TAB(16,17)ans$
3130 b$=ans$
3140 PRINT TAB(0,19)CHR$130;"If the num
bers have been entered"'CHR$130;"correct
ly, press";CHR$135;"C";CHR$130;"to carry
on."
3150 PRINT TAB(0,22)CHR$130;"If you hav
e made any mistakes,"'CHR$130;"press";CH
R$135;"A";CHR$130;"to start again."
3160 REPEAT:G$=GET$:UNTIL INSTR("CA",G$
)<>0
3170 IF G$="C" THEN figuresOK=TRUE ELSE
figuresOK=FALSE
3180 UNTIL figuresOK
3190 ENDPROC
3300 REM```````````````````````````````
`````````````````````````````````````
3310 DEFPROCinputseed
3315 seedsought=TRUE
3317 REPEAT
3320 CLS
3330 PRINT TAB(0,1)CHR$130;"Please ente
r a six digit number to"'CHR$130;"seed t
he random number generator."
3340 PRINT TAB(0,4)CHR$130;"If you wish
to have less than six"'CHR$130;"digits
in the seed, type leading zeros."CHR$130
;"e.g. if you want the seed to be";CHR$1
35;"321"'CHR$130;"then enter";CHR$135;"0
00321"
3350 PRINT TAB(0,9)CHR$130;"If you wish
you may use your birth"'CHR$130;"date.
For example if your birth date is 15 Apr
il 1963";CHR$130;"then enter";CHR$135;"1
50463"
3360 PRINT TAB(0,14)CHR$130;"Random num
ber generator seed:";CHR$135
3365 PRINT TAB(0,16)CHR$136"DON'T FORGE
T TO SWITCH ON YOUR PRINTER!"
3370 PROCinput("0123456789",6,31,14)
3380 PRINT TAB(0,19)CHR$130;"If the num
ber has been entered"'CHR$130;"correctly
, press";CHR$135;"C";CHR$130;"to carry o
n."
3390 PRINT TAB(0,22)CHR$130;"If you hav
e made any mistakes,"'CHR$130;"press";CH
R$135;"A";CHR$130;"to start again."
3400 REPEAT:G$=GET$:UNTIL INSTR("CA",G$
)<>0
3410 IF G$="C" THEN figureOK=TRUE ELSE
figureOK=FALSE
3420 UNTIL figureOK
3430 seed=RND(-(VAL(ans$)))
3440 ENDPROC
3500 REM```````````````````````````````
`````````````````````````````````````
3510 DEFPROCprintscreen:REM also sends
headings to printer
3520 CLS
3525 VDU2
3530 PRINT TAB(0,1)CHR$130;"WINNING NUM
BERS:";CHR$135;:FOR I=1 TO 6:PRINT wl$(I
);" ";:NEXT I:PRINT CHR$133;b$
3540 PRINT CHR$130;"RANDOM NUMBER GENER
ATOR SEED:";CHR$135;ans$
3550 PRINT CHR$146;STRING$(39,CHR$172)
3560 PRINT TAB(0,4)CHR$130;"No. of Num
bers generated Prizes won."'CHR$130;"Bo
ards by the computer."
3565 VDU3
3570 PRINT TAB(0,23)CHR$130;"Press the"
;CHR$135;"S";CHR$130;"key to stop the pr
ogram."
3580 VDU28,1,21,39,7
3590 ENDPROC
3700 REM```````````````````````````````
`````````````````````````````````````
3710 DEFPROCgenrndnos
3715 IF boards<>999999 THEN boards=boar
ds+1 ELSE boards=1
3720 Balls$=balls$
3730 num=50
3740 FOR I=1 TO 6
3750 num=num-1
3760 R=RND(num)
3770 r$(I)=MID$(Balls$,2*R-1,2)
3780 Balls$=LEFT$(Balls$,2*R-2)+RIGHT$(
Balls$,LEN(Balls$)-(2*R))
3790 NEXT I
3800 ENDPROC
3900 REM```````````````````````````````
`````````````````````````````````````
3910 DEFPROCtestformatches
3920 matches=0:bonusmatch=FALSE
3930 FOR I=1 TO 6
3940 Q=0:matchfound=FALSE
3950 REPEAT
3960 Q=Q+1
3970 IF r$(I)=wl$(Q) THEN matchfound=TR
UE:matches=matches+1
3980 UNTIL matchfound OR Q=6
3990 IF r$(I)=b$ THEN bonusmatch=TRUE
4000 NEXT I
4010 IF matches<3 THEN prize$="no prize
":np=np+1
4020 IF matches=3 THEN prize$="match3":
m3=m3+1
4030 IF matches=4 THEN prize$="match4":
m4=m4+1
4040 IF matches=5 AND NOT bonusmatch TH
EN prize$="match5":m5=m5+1
4050 IF matches=5 AND bonusmatch THEN p
rize$="match5+":m5p=m5p+1
4060 IF matches=6 THEN prize$="JACKPOT!
":jp=jp+1
4065 IF matches>startprint-1 THEN VDU2
ELSE VDU3
4070 PRINT FNpad(boards);" ";
4080 FOR I=1 TO 6:PRINT r$(I)" ";:NEXT
I:PRINT" ";prize$;
4085 IF prize$="no prize" AND bonusmatc
h THEN PRINT" ";matches;"b"
4086 IF prize$="no prize" AND NOT bonus
match THEN PRINT" ";matches
4087 IF prize$<>"no prize" AND bonusmat
ch THEN PRINT" ";"b"
4088 IF prize$<>"no prize" AND NOT bonu
smatch THEN PRINT""
4090 ENDPROC
4200 REM```````````````````````````````
`````````````````````````````````````
4210 DEFFNpad(A%)=STRING$(6-LEN(STR$(A%
))," ")+STR$(A%)
4300 REM```````````````````````````````
`````````````````````````````````````
4310 DEFPROCtestforstopping
4320 K$=INKEY$(1)
4330 IF K$="S" THEN wanttostop=TRUE ELS
E wanttostop=FALSE
4340 ENDPROC
4400 REM```````````````````````````````
`````````````````````````````````````
4410 DEFPROCsummary
4420 VDU26:CLS:VDU2
4430 PRINT'CHR$130;"No prize";CHR$135;T
AB(16)FNpad(np)
4440 PRINT'CHR$130;"Match3 prize";CHR$1
35;TAB(16)FNpad(m3)
4450 PRINT'CHR$130;"Match4 prize";CHR$1
35;TAB(16)FNpad(m4)
4460 PRINT'CHR$130;"Match5 prize";CHR$1
35;TAB(16)FNpad(m5)
4470 PRINT'CHR$130;"Match5+ prize";CHR$
135;TAB(16)FNpad(m5p)
4480 PRINT'CHR$130;"Jackpot";CHR$135;TA
B(16)FNpad(jp)
4485 PRINT'CHR$130;"TOTAL";CHR$135;TAB(
16)FNpad(boards)
4487 VDU3
4490 PRINT''CHR$130;"Press RETURN to fi
nish."
4500 REPEAT UNTIL GET=13
4510 ENDPROC
4600 REM```````````````````````````````
`````````````````````````````````````
4610 DEFPROCwhichtoprint
4620 CLS
4630 PRINT'CHR$130;"Every board is show
n on the screen."''CHR$130;"Only prize-w
inning boards are sent to"'CHR$130;"the
printer."
4640 PRINT TAB(0,6)CHR$130;"You can sav
e paper and ink by not"'CHR$130;"sending
the match3 wins to the printer."
4650 PRINT'' CHR$130;"Press the";CHR$13
5;"3";CHR$130;"key to send match3 wins t
o"'CHR$130;"the printer."
4660 PRINT' CHR$130;"Press the";CHR$135
;"4";CHR$130;"key to stop match3 wins"'C
HR$130;"being sent to the printer."
4670 REPEAT:G$=GET$:UNTIL INSTR("34",G$
)<>0
4680 IF G$="3" THEN startprint=3 ELSE s
tartprint=4
4690 ENDPROC
10000 DATA First,Second,Third,Fourth,Fif
th,Sixth