1 COMMON A, AL, B, BASEONLY, C, C$, C1, CAT$, CC, CKT$, D, D$, DD, DIA, DIMN$, DMS, E, EO, EX$, F, F$, FD, FF, FQ, FRQ, G$, GO$, I, I$, L, LATLONG, LD, LL, LN, LS, LW, LX, MAX, MENU, MIN, MX, N, NN, NT, OV, P, PI, PROG$, Q, QQ, QU, R, RA, RC, T, T$, U, U$, UH, UL$, V$, VC, W, WHIP, WIRD, WW, X, X$, X1, XS, Z$, ZP, ZS
5 'OMMON EX$,GO$
10 'RANDNUM - Random number Generator - 17 DEP 2005 rev. 26 APR 09
20 CLS:KEY OFF
30 IF EX$=""THEN EX$="EXIT"
40 IF PROG$=""THEN GO$=EX$ ELSE GO$=PROG$
45 PROG$="RANDNUM"
50 
60 '
70 '.....title page
80 CLS
90 COLOR 15,2,1
100 PRINT " Random Number Generator";TAB(57);"by George Murphy VE3ERP ";
110 COLOR 1,0:PRINT STRING$(80,223);
120 COLOR 15,2:LOCATE CSRLIN-1,25:PRINT " Algorithm by Robert Dehoney "
130 COLOR 7,0
140 '
150 PRINT:
160 PRINT " This program generates arrays of consecutive numbers and arranges";
170 PRINT " them in "
180 PRINT " random order."
190 PRINT:COLOR 7,0
200 PRINT " To RUN program.....press 1";
210 PRINT " To EXIT............press 0";
220 Z$=INKEY$
230 IF Z$="1"THEN CLS:COLOR 7,0,0:GOTO 260
240 IF Z$="0"THEN RUN EX$
250 GOTO 220
260 PRINT:COLOR 0,7
270 PRINT" Do you want 6 numbers between 1 and 49 for Lotto 649?  (y/n) "
275 L$=INKEY$
280 IF L$="n" OR L$="N" THEN 310
290 IF L$="y" OR L$="Y" THEN COLOR 7,0:N=49:GOTO 350
300 GOTO 275
310 PRINT:COLOR 0,7
320 INPUT;" ENTER last number in array (1 to";N
330 COLOR 7,0
340 IF N=49 THEN L$="y"
350 DIM L(N),P(N)
360 CLS:RANDOMIZE TIMER
370 COLOR 0,7:PRINT " RANDOM NUMBER GENERATOR ";:COLOR 7,0
380 PRINT
390 COLOR 0,7:PRINT " Numbers from 1 to";N;;"in random order ";:COLOR 7,0
400 PRINT
410 FOR I=1 TO N:L(I)=I:NEXT I
420 FOR J=N TO 1 STEP-1
430 X=RND:R=INT(X*J+1)
440 P(J)=L(R)
450 L(R)=L(J)
460 PRINT P(J);
470 NEXT J
480 PRINT:PRINT
490 IF L$="n" THEN 740
500 '
510 COLOR 0,7:PRINT " LOTTO 649 pick: ";
520 COLOR 7,0:PRINT "  ";
530 FOR Z=1 TO 7
540 Q(Z)=P(Z)
550 NEXT Z
560 '
570 '.....sort
580 SN=6  '(no. of data)
590 SM=SN
600 SM=INT(SM/2):IF SM=0 THEN 680
610 SK=SN-SM:SJ=1
620 SI=SJ
630 SL=SI+SM
640 IF Q(SI)<=Q(SL)THEN 660 ELSE SWAP Q(SI),Q(SL)
650 SI=SI-SM:IF SI>0 THEN 630
660 SJ=SJ+1:IF SJ>SK THEN 600
670 GOTO 620
680 '.....sort completed
690 COLOR 0,7
700 FOR Z=1 TO 6
710 PRINT Q(Z);
720 NEXT Z
730 PRINT "лл Bonus ";Q(7)
740 COLOR 7,0:PRINT:PRINT
750 PRINT "For a new set of";N;;"numbers press 1"
760 PRINT "For a new array press 2"
770 PRINT "To exit press 0"
780 Z$=INKEY$
790 IF Z$="1"THEN 360
800 IF Z$="2"THEN ERASE L,P:L$="n":GOTO 320
810 IF Z$="0"THEN GOSUB 840:ERASE L,P:L$="n":GOTO 70
820 GOTO 780
830 '
840 '.....PRT
850 KEY OFF:GOSUB 920:LOCATE 25,5:COLOR 0,2
860 PRINT " Send this page to:(1)Printer Queue? (2)Printout? ";
870 PRINT "(3)Next page? (1/2/3)";:COLOR 7,0
880 Z$=INKEY$:IF Z$<"1"OR Z$>"3"THEN 880 ELSE GOSUB 920
890 IF Z$="3"THEN RETURN
900 FOR I%=1 TO 24:FOR J%=1 TO 80:LPRINT CHR$(SCREEN(I%,J%));:NEXT J%:NEXT I%
910 IF Z$="2"THEN LPRINT CHR$(12) ELSE 850
920 LOCATE 25,1:PRINT STRING$(80,32);:RETURN
