8-Bit Software Online Conversion

Random Numbers - Listing

10 REM Pgm. name:UNIFVAL To generate a stream of random nos.in the range 1 to 49 with virtually equal nos. of each va lue. 20 MODE7 30 VDU23,1,0;0;0;0; 40 DIM A(49),A$(49) 50 count=0:hop$=" 1 2 3 4 5 6 7 8 910 1112131415161718192021222324252627282930 31323334353637383940414243444546474849": ins=0:fnine$=STRING$(147,"*"):fnine$="" 60 FOR I=1 TO 49:A$(I)=MID$(hop$,I*2- 1,2):NEXT I 70 CLS 80 PRINT TAB(0,15)CHR$130;"Last 49 ra ndom numbers generated:";TAB(0,21)CHR$13 0;"A long press to";CHR$135;"P";CHR$130; "to pause, then:";TAB(0,22)CHR$130;"Pres s";CHR$135;"R";CHR$130;"to resume or";CH R$135;"F";CHR$130;"to finish." 90 PRINT TAB(0,23)CHR$130;"No. of ran dom nos. generated:";CHR$135 100 FOR N=1 TO 49:PROCgetxandy:PRINT T AB(x,y)CHR$130;FNpad(N);CHR$135:NEXT N 110 REPEAT 120 PROCgenrandnum:A(N)=A(N)+1:PROCget xandy:PRINT TAB(x+4,y)FNpAd(A(N)) 130 UNTIL wanttofinish 140 VDU31,0,23,23,1,1;0;0;0; 150 END 160 REM``````````````````````````````` `````````````````````````````````````` 170 DEFPROCgetxandy 180 IF N<14 THEN x=0:y=N 190 IF N>13 AND N<27 THEN x=10:y=N-13 200 IF N>26 AND N<40 THEN x=20:y=N-26 210 IF N>39 THEN x=30:y=N-39 220 ENDPROC 230 REM``````````````````````````````` ````````````````````````````````````` 240 DEFFNpad(Q) 250 IF LEN(STR$(Q))=2 THEN =STR$(Q) EL SE =" "+STR$(Q) 260 REM``````````````````````````````` ````````````````````````````````````` 270 DEFFNpAd(Q)=STRING$(6-LEN(STR$(Q)) ,".")+STR$(Q) 280 REM``````````````````````````````` `````````````````````````````````````` 290 DEFPROCgenrandnum 300 count=count+1:PRINT TAB(31,23);cou nt 310 IF ins=49 THEN ins=1 ELSE ins=ins+ 1 320 R=RND(49) 330 r$=MID$(hop$,2*R-1,2):N=VAL(r$) 340 hop$=LEFT$(hop$,2*R-2)+A$(ins)+RIG HT$(hop$,LEN(hop$)-(2*R)) 350 fnine$=fnine$+r$+" ":IF LEN(fnine$ )=147 THEN VDU28,1,19,39,16:PRINT fnine$ ;:VDU26:fnine$="" 360 G$="*":IF fnine$="" AND INKEY$(1)= "P" THEN REPEAT:G$=GET$:UNTIL INSTR("RF" ,G$)<>0 370 IF G$="F" THEN wanttofinish=TRUE E LSE wanttofinish=FALSE 380 ENDPROC