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