home *** CD-ROM | disk | FTP | other *** search
- ROW% = CSRLIN
- COL% = POS(0)
- CLR% = SCREEN(ROW%, COL%, 1)
- DIM J(16)
- LOOPF:
- FOR X = 1 TO 16
- READ J(X)
- A% = J(X)
- F% = A%
- GOSUB MULTF:
- NEXT X
-
- GOSUB FNDBG:
- GOTO STRTM:
-
- DATA 0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15
- DATA 0,16,32,48,64,80,96,112
- MULTF:
- FOR Y = 1 TO 8
- IF A% <> CLR% THEN
- A% = A% + 16
- END IF
- IF A% = CLR% THEN
- Y = 8
- X = 16
- END IF
- NEXT Y
- RETURN
-
- FNDBG:
- DIM K(24)
- LOOPB:
- FOR Z = 17 TO 24
- READ K(Z)
- C% = K(Z)
- GOSUB MULTB:
- NEXT Z
-
- MULTB:
- FOR W = 1 TO 16
- IF C% <> CLR% THEN
- C% = C% + 1
- END IF
- IF C% = CLR% THEN
- W = 16
- Z = 24
- END IF
- NEXT W
- IF C% >= 0 AND C% <= 15 THEN
- B% = 0
- ELSEIF C% >= 16 AND C% <= 31 THEN
- B% = 1
- ELSEIF C% >= 32 AND C% <= 47 THEN
- B% = 2
- ELSEIF C% >= 48 AND C% <= 63 THEN
- B% = 3
- ELSEIF C% >= 64 AND C% <= 79 THEN
- B% = 4
- ELSEIF C% >= 80 AND C% <= 95 THEN
- B% = 5
- ELSEIF C% >= 96 AND C% <= 111 THEN
- B% = 6
- ELSEIF C% >= 112 AND C% <= 127 THEN
- B% = 7
- END IF
- RETURN
-
- STRTM:
- LOCATE ROW%, COL%
- COLOR F%, B%
- PRINT "Do you wish to read documentation before proceeding ? (Y/N) ";
- THTY:
- S$ = INKEY$
- IF S$ = "" THEN
- GOTO THTY:
- ELSEIF S$ = "y" OR S$ = "Y" THEN
- GOSUB PRTDOC:
- END IF
-
- MAIN:
- GOSUB CLRLIN:
- D% = 0
- E% = 0
- L% = 0
- T = 0
- B = 0
-
- GETNUMS:
- LOCATE ROW%, COL%
- INPUT "Enter a number to represent bottom of range : ", B
- GOSUB CLRLIN:
- INPUT "Enter a number to represent top of range....: ", T
-
- COMPTB:
- IF T > 0 AND B > T THEN
- GOSUB CLRLIN:
- PRINT "Top of rang must be greater than bottom of range."
- GOSUB CHCKEY:
- GOTO MAIN:
- END IF
-
- TTOOLGE:
- IF T > 9999999! THEN
- GOSUB CLRLIN:
- PRINT "Number entered for top of range is out of processing range."
- GOSUB CHCKEY:
- GOTO MAIN:
- END IF
-
- BTOOLGE:
- IF B > 9999999! THEN
- GOSUB CLRLIN:
- PRINT "Number entered for bottom of range is out of processing range."
- GOSUB CHCKEY:
- GOTO MAIN:
- END IF
-
- GRTR:
- IF T > 0 AND B > 0 THEN
- GOTO GETLENT:
- END IF
-
- GETLEN:
- GOSUB CLRLIN:
- INPUT "Enter number of digits for output...........: ", D%
- IF T <= 0 THEN
- GOTO DEFRNDNUM:
- END IF
-
- GETLENT:
- IF T > 0 THEN
- GOSUB FNDE:
- END IF
-
- GETLENB:
- IF B > 0 THEN
- GOSUB FNDL:
- END IF
-
- COMPLEN:
- IF T > 0 AND D% > E% THEN
- GOSUB CLRLIN:
- PRINT "Number of digits for output must not excede"
- PRINT "the number of digits in the top range entry."
- GOSUB CHCKEY:
- GOTO MAIN:
- END IF
-
- EQAL:
- IF T > 0 AND D% = E% THEN
- GOTO DEFRNDNUM
- END IF
-
- VARLEN:
- GOSUB GETRNDNUM:
- P = I
- IF T > 0 AND P > E% THEN
- GOTO VARLEN:
- ELSEIF B > 0 AND P < L% THEN
- GOTO VARLEN:
- END IF
- D% = P
-
- DEFRNDNUM:
- V = 0
- FOR W = 0 TO (D% - 1)
- GOSUB GETRNDNUM:
- V = V + (I * 10 ^ W)
- NEXT W
- N = INT(V)
-
- CMPRNDNUM:
- IF B = 0 AND T = 0 THEN
- GOTO GOODCMP:
- END IF
-
- IF N < B THEN
- GOTO DEFRNDNUM:
- END IF
-
- IF T > 0 AND N > T THEN
- GOTO DEFRNDNUM:
- END IF
-
- IF N >= B THEN
- GOTO FOTN:
- ELSE
- GOTO DEFRNDNUM:
- END IF
-
- FOTN:
- IF T > 0 THEN
- GOTO FOTW:
- ELSE
- GOTO GOODCMP:
- END IF
-
- FOTW:
- IF N <= T THEN
- GOTO GOODCMP:
- END IF
-
- GOODCMP:
- PRINT N
- LOCATE ROW%, COL%
- PRINT "Would you like to try another set of numbers ? (Y/N) ";
-
- FOSE:
- A$ = INKEY$
- IF A$ = "" THEN
- GOTO FOSE:
- ELSEIF A$ = "Y" OR A$ = "y" THEN
- GOTO MAIN:
- ELSEIF A$ = "N" OR A$ = "n" THEN
- LOCATE ROW%, COL%
- PRINT "Controlled Random Number Generator by J. Johnson"
- PRINT "Copyright 1992 Red Moon Software "
- END IF
-
- END
-
- GETRNDNUM:
- RANDOMIZE TIMER
- R = RND(X)
- F$ = STR$(R)
- H = E%
- IF H > 7 THEN
- H = H - 6
- END IF
- IF H <= 1 THEN
- H = H + 2
- END IF
- J$ = RIGHT$(F$, H)
- Q$ = LEFT$(J$, 1)
- I = VAL(Q$)
- RETURN
-
- FNDE:
- IF T <= 9 THEN
- E% = 1
- ELSEIF T <= 99 THEN
- E% = 2
- ELSEIF T <= 999 THEN
- E% = 3
- ELSEIF T <= 9999 THEN
- E% = 4
- ELSEIF T <= 99999 THEN
- E% = 5
- ELSEIF T <= 999999 THEN
- E% = 6
- ELSEIF T <= 9999999 THEN
- E% = 7
- END IF
- RETURN
-
- FNDL:
- IF B <= 9 THEN
- L% = 1
- ELSEIF B <= 99 THEN
- L% = 2
- ELSEIF B <= 999 THEN
- L% = 3
- ELSEIF B <= 9999 THEN
- L% = 4
- ELSEIF B <= 99999 THEN
- L% = 5
- ELSEIF B <= 999999 THEN
- L% = 6
- ELSEIF B <= 9999999 THEN
- L% = 7
- END IF
- RETURN
-
- PRTDOC:
- CLS
- PRINT
- PRINT " This program will generate a random number defined by your input to the"
- PRINT " initial program prompts. The first of which will ask you for a number"
- PRINT " representing the bottom of the user defined range (lowest number to accept)."
- PRINT " The second will ask for a number to represent the top of the range (highest"
- PRINT " number to accept). The third will ask for the number of digits required for"
- PRINT " output (how many digits do you need ?). If you provide input to both the"
- PRINT " first and second prompts, the the third prompt will not appear."
- PRINT
- PRINT " You may wish to skip one of the first two prompts to create a lower or"
- PRINT " higher bound to the output. For instance, if you wanted a three digit number"
- PRINT " that is not lower than 25, then you would answer the first prompt with 25,"
- PRINT " leave the second prompt empty (press the ENTER key), and enter 3 to the third"
- PRINT " prompt. If you wanted a 2 digit number that is no higher than 80, then you"
- PRINT " would leave the first prompt empty, enter 80 to the second prompt, and enter"
- PRINT " 2 to the third prompt."
- PRINT
- PRINT " To create a hi/low range for the generated number, just enter the low"
- PRINT " number at the first prompt and the high number at the second prompt. To"
- PRINT " create any 5 digit number, leave the first 2 prompts empty and enter 5 to the"
- PRINT " the third prompt."
- PRINT
- GOSUB CHCKEY:
- CLS
- PRINT
- PRINT "Precauations:"
- PRINT
- PRINT " - Bottom and Top of range inputs cannot excede 9,999,999."
- PRINT
- PRINT " - Top of range value must be higher than the value of the bottom"
- PRINT " range."
- PRINT
- PRINT " - The number of digits required for output cannot excede the"
- PRINT " number of digits in the top of range value."
- PRINT
- PRINT " - Tight ranges (i.e. bottom range = 3 and top of range = 6) will"
- PRINT " require a much longer period of time to process than wide ranges"
- PRINT " (i.e. bottom of range = 120 and top of range =1000)."
- PRINT ""
- GOSUB CHCKEY:
- CLS
- RETURN
-
- CHCKEY:
- PRINT "Press any key to continue...";
-
- TNSY:
- S$ = INKEY$
- IF S$ = "" THEN
- GOTO TNSY:
- END IF
- RETURN
-
- CLRLIN:
- LOCATE ROW%, COL%
- PRINT " "
- PRINT " "
- LOCATE ROW%, COL%
- RETURN
-
-