10REM" LOTGOOD
20REM J.Davis '96.
30MODE7
40DIMA%(6):DIMB%(10,6)
50DIMI%(7):DIMW%(7):DIMK$(8)
60W%(0)=0:W%(1)=0:W%(2)=0:W%(3)=10:W%
(4)=100:W%(5)=2000:W%(6)=2000000:W%(7)=2
00000
70R%=0:DEMO%=0:PR%=1:FP%=0
80*FX202,32
90L$=" * L O T G O O
D *"
100FORN%=1TO8
110READK$(N%)
120NEXT
130DATAAaahh!,Bliss!,Wow!,Ya-Hoo!,Oops
!,Eek!,Ouch!,Damn!
140VDU23,1,0;0;0;0;
150PRINTL$
160PRINTTAB(0,3)" Press: I for Info.
M for Menu."
170PRINT'CHR$(145);STRING$(39,"/");
180FORN%=8TO22:PRINTTAB(0,N%)" ";:NEXT
190PRINTTAB(2,24);CHR$(145);STRING$(34
,"/");
200G$=INKEY$(0)
210IF G$="I" THEN280
220IF G$="M" THEN530
230PRINTTAB(1+RND(34),7+RND(15))" "CHR
$(32+(64ANDRND(1)>.30)+(159ANDRND(0)>.35
));
240IF RND(1)>.96 PRINTTAB(2+RND(22),8+
RND(13))" ?FEEL?GOOD?";
250IF RND(1)>.96 PRINTTAB(3+RND(31),8+
RND(13));CHR$(128+RND(6));"¶ ";
260IF RND(1)>.99 PRINTTAB(36,7+RND(15)
)" "
270GOTO200
280CLS:VDU23,1,1;0;0;0;
290PRINTL$:PRINT
300PRINT" This is a lottery program
(oh no, not anoth...) with a built-in fe
el-good factor - usually. First the
computer chooses ten random sets of s
ix lottery"
310PRINT" numbers, and then, with your
help, selects just one of them for
you to place your one pound on. The
idea is that you will feel good beca
use you saved £9 by betting on just
one set instead of all ten."
320PRINT" Of course, this assumes th
at although you are unlikely to win anyt
hing on your selected set, you would
n't have been likely to win anything
on any of the other nine either."
330PRINT" To feel good, this will ha
ve to be checked, which the program w
ill do for you. The ten sets are saved
to a file called 'LOTSETS' - there is
a dummy file included."
340PRINT'CHR$(145);STRING$(39,",");
350PRINTSPC(25);"Press SPACE";
360G=GET:CLS
370PRINTL$:PRINT
380PRINT" Your total feel-good facto
r, given by the program, is the sum of t
he £9 you have saved plus any money yo
u won, minus any winnings that happ
ened to"
390PRINT" come up - perish the thought
- on the other nine possible entries.
"
400PRINT" The program assumes that g
etting four numbers right wins £100, 5=
£2000, 5 + bonus= £200,000 and 6= £2mil
lion. If you wish to change these, ju
st change the values assigned to W%(7)
."
410PRINT" To try out the program, yo
u could enter seven imaginary number
s as the lottery result, after genera
ting or loading the ten sets of numb
ers, or use the Demo."
420PRINT'CHR$(145);STRING$(39,",");
430PRINT'SPC(25);"Press SPACE";
440G=GET:CLS
450PRINTL$:PRINT
460PRINT" 1) Before the draw, use N f
rom the menu to get first the ten se
ts of numbers, and then use SPACE
at the prompt to select your partic
ular set. You will then be given the o
ption of saving these to LOTSETS."
470PRINT
480PRINT" 2) After the draw, use E fr
om the menu to enter the result of the l
ottery, and then L to load the file, the
n F for all the results and the good (?)
news about";
490PRINT" your feel-good factor. There
is also a print option for the results
screen."
500PRINT'CHR$(145);STRING$(39,",");
510PRINT'SPC(18)"Press SPACE for Menu"
;
520G=GET
530ONERROR ONERROROFF:VDU23,1,1;0;0;0;
:PRINTTAB(0,22);:END
540CLS
550VDU23,1,0;0;0;0;
560IF DEMO%=1 PROCcleardemo
570DEMO%=0:S=1
580PRINTL$:PRINT
590PRINTTAB(14)" "CHR$(157)" MENU "CH
R$(156):PRINT
600PRINT" Most operations happen fro
m this menu. They may be used in an
y order, but note that Demo will wipe
out all current data."
610PRINT
620PRINT" PRESS: N for ten sets of Ne
w Numbers. V to View current se
ts."
630PRINT" L to Load file LOTSE
TS. E to Enter lottery r
esult."
640PRINTTAB(8)" F for Full Feel-good r
esults. D for continuous Demo.
"
650PRINTTAB(8)" I for Info.
ESC to Quit."
660PRINT'''CHR$(145);STRING$(39,"/");
670PRINTTAB(7,2);
680G$=GET$
690ONERROR GOTO530
700IF G$="N" PROCtensets
710IF G$="V" PROCview
720IF G$="L" PROCload
730IF G$="E" PROCentlot
740IF G$="F" PROCfullres
750IF FP%=1 PROCprint
760IF G$="D" PROCdemo
770IF G$="I" THEN280
780IF G$="|" PROClotsave:REM not menu
790IF G$="÷" PROClotload:REM not menu
800IF G$="£" PROClottery:REM not menu
810GOTO530
820" **
830DEFPROCtensets
840PROCscreen
850IF DEMO%=1 PROCdeminfo
860Z=RND(-TIME)
870F%=0:R%=0
880FORM%=1TO10
890A%(1)=RND(49)
900FORN%=1TO5
910Z%=RND(49)
920FORL%=1TON%
930IFZ%=A%(L%) F%=1:L%=N%
940NEXT
950IF F%=1 F%=0:GOTO910
960A%(L%)=Z%
970NEXT
980PROCsort
990PROCstorprnt
1000PRINT'
1010NEXT
1020IF DEMO%=1 ENDPROC
1030PRINTTAB(0,22)" Press: D for Differ
ent sets of numbers. S to Select
your one set. SPACE for Me
nu.";
1040G$=GET$
1050IF G$="D" FORN%=1TO10:PRINTTAB(4,N%
*2)" ":NEXT:GOTO870
1060IF G$="S" PROCselect:ENDPROC
1070IF G$=" " ENDPROC
1080GOTO1040
1090" **
1100DEFPROCload
1110PROCloadsets
1120PROCscreen
1130PROCprintsets
1140PRINTTAB(0,23)" Press: E to Enter l
ottery result. SPACE for Me
nu.";
1150G$=GET$
1160IF G$=" " ENDPROC
1170IF G$<>"E" THEN1150
1180PROCentlot
1190ENDPROC
1200" **
1210DEFPROCview
1220PROCscreen
1230PROCprintsets
1240IF B%(1,1)=0 PRINTTAB(0,22)" Hmmm..
."
1250PRINTTAB(0,23+(1ANDB%(1,1)=0))" Pre
ss SPACE for Menu.";
1260IFGET<>32THEN1260
1270ENDPROC
1280" **
1290DEFPROCfullres
1300PROCscreen
1310PROCprintsets
1320PROCprntreslot
1330PROCcheckwin
1340IF B%(1,1)<>0 AND I%(1)<>0 GOTO1400
1350IF B%(1,1)=0 AND I%(1)=0 PRINTTAB(0
,22)" This is very silly.
Can we have some data please."
1360IF B%(1,1)=0 EOR I%(1)=0 PRINTTAB(0
,22)" Haven't we forgotten something?"
1370PRINTTAB(0,24)" Press SPACE for Men
u.";
1380IFGET<>32THEN1380
1390ENDPROC
1400PROCfgfactor
1410FP%=1
1420ENDPROC
1430G$=GET$
1440IF G$=" " ENDPROC
1450IF G$="P" FP%=1:ENDPROC
1460IF G$="|" PR%=PR%*-1
1470PRINTTAB(38,24);CHR$(32+(223ANDPR%=
-1));
1480GOTO1430
1490" **
1500DEFPROCentlot
1510ONERROR FORN%=1TO7:I%(N%)=0:NEXT:GO
TO530
1520F%=0
1530CLS:PRINTL$:PRINT
1540PRINTTAB(8)" "CHR$(157)" LOTTERY RE
SULT "CHR$(156)
1550PRINT'" First enter the six main
lottery numbers, in any order, and
then the bonus number."
1560VDU23,1,1;0;0;0;
1570FORN%=1TO6
1580PRINT'" Number ";N%;"?"
1590NEXT
1600PRINT'" Bonus?"
1610PRINTTAB(0,22)CHR$(145);STRING$(39,
",");
1620PRINT'" Press ESC for Menu.";
1630FORN%=1TO6
1640PRINTTAB(11,N%*2+6);
1650INPUT" "I%(N%)
1660GOSUB1790:IF F%=1 F%=0:GOTO1640
1670NEXT
1680PRINTTAB(8,N%*2+6);
1690INPUT" "I%(7)
1700GOSUB1790:IF F%=1 F%=0:GOTO1680
1710PROCsortlot
1720ONERROR GOTO530
1730PRINTTAB(0,24)" Are these all corre
ct? (Y/N)";
1740G$=GET$
1750IF G$="N" THEN1510
1760IF G$<>"Y" THEN1740
1770ENDPROC
1780" **
1790IF I%(N%)>0 AND I%(N%)<50 RETURN
1800F%=1:VDU7
1810PRINTTAB(18,N%*2+6)" Out of range."
TAB(19,N%*2+7)"Press SPACE";
1820G=GET
1830PRINTTAB(11-(3ANDN%=7),N%*2+6)SPC(2
6)TAB(19,N%*2+7)SPC(18)
1840RETURN
1850" **
1860DEFPROCsortlot
1870FORL%=1TO5
1880K%=I%(6)
1890FORN%=5TOL% STEP-1
1900IFK%>I%(N%) K%=I%(N%) ELSE I%(N%+1)
=I%(N%):I%(N%)=K%
1910NEXT:NEXT
1920ENDPROC
1930" **
1940DEFPROCscreen
1950IF FP%=0 CLS
1960VDU23,1,0;0;0;0;
1970PRINTL$:PRINT
1980FORN%=1TO10
1990N$=STR$(N%)
2000IFN%<10 N$=N$+":"
2010PRINTTAB(26,N%*2);CHR$(156)
2020PRINTTAB(0,N%*2);" ";N$;CHR$(157);"
"
2030NEXT
2040ENDPROC
2050" **
2060DEFPROCsort
2070FORL%=1TO5
2080K%=A%(6)
2090FORN%=5TOL% STEP-1
2100IFK%>A%(N%) K%=A%(N%) ELSE A%(N%+1)
=A%(N%):A%(N%)=K%
2110NEXT:NEXT
2120ENDPROC
2130" **
2140DEFPROCstorprnt
2150FORN%=1TO6
2160B%(M%,N%)=A%(N%)
2170PRINTTAB(N%*3+3,M%*2);A%(N%);" ";
2180NEXT
2190PRINTTAB(4,M%*2)" "
2200ENDPROC
2210" **
2220DEFPROCselect
2230IF DEMO%=1 THEN2260
2240PRINTTAB(0,22);SPC(118);
2250PRINTTAB(0,23)" Press SPACE to ma
ke your selection."
2260RR%=1
2270R%=RND(10)
2280PRINTTAB(0,RR%*2);" "
2290PRINTTAB(0,R%*2);" "
2300FORD=1TO80:NEXT
2310RR%=R%
2320IF DEMO%=1 IF RND(20+(10ANDS=1))=1
THEN2340
2330IF INKEY$(0)<>" " THEN2270
2340PRINTTAB(24,R%*2);" * Your Entry";
2350IF DEMO%=1 ENDPROC
2360PRINTTAB(0,22)" Press: S to Save as
LOTSETS. SPACE for Me
nu. ";
2370G$=GET$
2380IF G$=" " ENDPROC
2390IF G$<>"S" THEN2370
2400PROCsave
2410PRINTTAB(0,23)" Press SPACE for Men
u.";
2420IFGET<>32THEN2420
2430ENDPROC
2440" **
2450DEFPROCsave
2460PRINTTAB(0,22);SPC(80);
2470PRINTTAB(0,23);" Saving..."
2480Z=OPENOUT"LOTSETS"
2490FORM%=1TO10
2500FORN%=1TO6
2510PRINT#Z,B%(M%,N%)
2520NEXT:NEXT
2530PRINT#Z,R%
2540CLOSE#Z
2550PRINTTAB(0,23);" "
2560ENDPROC
2570" **
2580DEFPROClotsave
2590Z=OPENOUT"LOTRES"
2600FORN%=1TO7
2610PRINT#Z,I%(N%)
2620NEXT
2630CLOSE#Z
2640ENDPROC
2650" **
2660DEFPROCloadsets
2670ONERROR VDU7:PRINTTAB(7,18);" FILE
NOT FOUND: PRESS SPACE.";:G=GET:GOTO53
0
2680PRINTTAB(8,18)" Loading..."
2690Z=OPENIN"LOTSETS"
2700FORM%=1TO10
2710FORN%=1TO6
2720INPUT#Z,B%(M%,N%)
2730NEXT:NEXT
2740INPUT#Z,R%
2750CLOSE#Z
2760ONERROR GOTO530
2770ENDPROC
2780" **
2790DEFPROClotload
2800Z=OPENIN"LOTRES"
2810FORN%=1TO7
2820INPUT#Z,I%(N%)
2830NEXT
2840CLOSE#Z
2850ENDPROC
2860" **
2870DEFPROCprintsets
2880FORM%=1TO10
2890FORN%=1TO6
2900PRINTTAB(N%*3+3,M%*2);B%(M%,N%);
2910NEXT
2920NEXT
2930IF R%=0 ENDPROC
2940PRINTTAB(0,R%*2);" "
2950PRINTTAB(24,R%*2);" * Your Entry";
2960ENDPROC
2970" **
2980DEFPROCprntreslot
2990PRINTTAB(0,1);" Lot:"
3000FORN%=1TO6
3010FORM%=1TO1+(40ANDS=1)
3020PRINTTAB(N%*3+2,1)" ";I%(N%)" "
3030PRINTTAB(N%*3+2,1);" "
3040NEXT:NEXT
3050PRINTTAB(23,1);" ";I%(7)
3060ENDPROC
3070" **
3080DEFPROCcheckwin
3090PRINTTAB(27,1);" Hit £Win";
3100WT%=0:WR%=0
3110FORL%=1TO10
3120C%=0:F%=0
3130FORM%=1TO6
3140FORN%=1TO6
3150IF I%(M%)=B%(L%,N%) C%=C%+1:PRINTTA
B(N%*3+2,L%*2);" ";TAB(N%*3+5,L%*2);" "
3160NEXT:NEXT
3170IF C%>6 C%=0
3180IF C%<>5 THEN3220
3190FORN%=1TO6
3200IF I%(7)=B%(L%,N%) F%=2:N%=6
3210NEXT
3220PRINTTAB(27,L%*2);" ";C%;"
";TAB(31,L%*2);" £";W%(C%+F%)
3230IF L%=R% WR%=W%(C%+F%)
3240WT%=WT%+W%(C%+F%)
3250NEXT
3260IF WR%=W%(7) PRINTTAB(23,1)" ":PRIN
TTAB(26,1)" "
3270ENDPROC
3280" **
3290DEFPROCfgfactor
3300FG%=9+(1ANDR%=0)+2*WR%-WT%
3310FGT%=FGT%+FG%
3320IF WR%>10000 AND DEMO%=0 PROCfivebs
ix
3330PRINTTAB(11,22);" ";CHR$(157);" FEE
L-GOOD FACTOR: ";
3340IF FG%>=0 PRINTTAB(32,22)"+"; ELSE
PRINTTAB(32,22)"-";
3350PRINT;ABS(FG%);
3360PRINTTAB(11,23);" ";CHR$(157);
3370IF DEMO%=1 PRINTTAB(11,23);" ";CHR$
(157);" Av.(";CD%;"):";INT(FGT%/CD%*10)/
10;
3380K%=1+(1ANDFG%>10)+(1ANDFG%>50)+(1AN
DFG%>200)+(4ANDFG%<1)+(1ANDFG%<-19)+(1AN
DFG%<-80)+(1ANDFG%<-500)
3390PRINTTAB(31,23);" "K$(K%);
3400IF FG%<0 PRINTTAB(8,0)"N"
3410ENDPROC
3420" **
3430DEFPROCfivebsix
3440VDU7
3450PRINTTAB(0,21)" My friend! We hav
en't met in a while, but you do remember
your old chum, don't you? My grann
y still needs that expensive operation
, and... <SPACE>";
3460G=GET
3470PRINTTAB(0,21);SPC(159);
3480ENDPROC
3490" **
3500DEFPROClottery
3510F%=0
3520I%(1)=RND(49)
3530FORN%=1TO6
3540Z%=RND(49)
3550FORL%=1TON%
3560IF Z%=I%(L%) F%=1:L%=N%
3570NEXT
3580IF F%=1 F%=0:GOTO3540
3590I%(L%)=Z%
3600NEXT
3610PROCsortlot
3620IF DEMO%=0 PRINTTAB(8,18)" OK.":G=I
NKEY(100)
3630ENDPROC
3640" **
3650DEFPROCdemo
3660RESTORE4100
3670CLS
3680PRINTL$:PRINT
3690PRINTTAB(24);CHR$(156);TAB(13,2);"
";CHR$(157);" DEMO":PRINT
3700PRINT" The demo runs continuously
until you exit to the menu with Escape
."
3710PRINT'" In each run, first ten ra
ndom sets of potential lottery entries a
re created. Then the one that would be
your actual entry is randomly highlight
ed. Then an imaginary random lottery dr
aw takes"
3720PRINT" place, instead of the one yo
u would usually enter directly, and
the results are displayed, including the
feel-good factor."
3730PRINT'CHR$(145);STRING$(39,",");
3740VDU23,1,1;0;0;0;
3750PRINTTAB(25);"Press SPACE";
3760G=GET
3770VDU23,1,0;0;0;0;
3780CD%=0:DEMO%=1:S=1:FGT%=0
3790B=1:IK=0
3800PROCtensets
3810CD%=CD%+1
3820PROCkey
3830PROCselect
3840PROCkey
3850PROClottery
3860PROCprntreslot
3870PROCkey
3880PROCcheckwin
3890PROCkey
3900PROCfgfactor
3910IF WT%>100 IF B=1 VDU7:VDU7
3920IF S=-1 IK=150+(200ANDWT%>10)+(300A
NDWT%>20)
3930IF WT%>1000 PROCpause
3940PROCkey:IK=0:RESTORE4100
3950GOTO3800
3960" **
3970DEFPROCdeminfo
3980PRINTTAB(0,22);" DEMO MODE"
3990PRINTTAB(0,23);" ¶¶¶¶¶¶¶¶¶"
4000PRINTTAB(0,24);" ESC: Menu P/P: P
ause/Go S/S:";CHR$(132+S*2);"Speed";
4010ENDPROC
4020" **
4030DEFPROCkey
4040READZ%
4050Z$=INKEY$(IK+(Z%ANDS=1))
4060IF Z$="S" S=S*-1:PRINTTAB(33,24);CH
R$(132+S*2);
4070IF Z$="B" B=B*-1
4080IF Z$<>"P" ENDPROC
4090PROCpause
4100DATA 150,150,150,200,700
4110ENDPROC
4120" **
4130DEFPROCcleardemo
4140FORN%=1TO10:FORM%=1TO6
4150B%(N%,M%)=0
4160NEXT:NEXT
4170FORN%=1TO7:I%(N%)=0:NEXT
4180R%=0
4190ENDPROC
4200" **
4210DEFPROCpause
4220PRINTTAB(2,23);" PAUSE "
4230G$=GET$:IF G$<>"P" THEN4230
4240PRINTTAB(0,23);" ¶¶¶¶¶¶¶¶¶";
4250ENDPROC
4260" **
4270DEFPROCprint
4280ONERROR VDU3:PR%=1:FP%=0:GOTO530
4290PRINTTAB(0,24)" Press: SPACE for Me
nu: P to Print. ";
4300G$=GET$
4310IF G$=" " FP%=0:PR%=1:ENDPROC
4320IF G$="P" THEN4360
4330IF G$="|" PR%=PR%*-1
4340PRINTTAB(38,24);CHR$(32+(223ANDPR%=
-1));
4350GOTO4300
4360IF PR%=1 VDU2 ELSE PR%=1
4370PRINTTAB(0,0);
4380FORN%=31744TO32703 STEP40
4390FORM%=0TO39
4400Z%=?(N%+M%)
4410?(N%+M%-1200)=Z%
4420IF Z%<32 OR Z%>123 Z%=32
4430PRINTCHR$(Z%);
4440IF Z%=35 ?(N%+M%)=35
4450REM" Gives £ on screen and printer
4460NEXT
4470VDU13
4480NEXT
4490VDU13
4500VDU3
4510FORN%=30544TO31503
4520?(N%+1200)=?N%
4530NEXT
4540GOTO4340
4550" **
4560REM At Print option, can print to
screen only, instead of screen and
printer, by first pressing |. Must be
done each time.
4570REM From the menu, not shown, the
lottery result can be saved to LOTRES
with "|" and loaded with "÷". Also, a
random lottery result can be generated
with "£".
4580REM Beep in demo can be toggled on/
off with B.
4590REM If the feel-good factor is
negative, the header bar changes -
slightly.