home *** CD-ROM | disk | FTP | other *** search
/ CD Actual 14 / CDACTUAL.iso / cdactual / demobin / share / program / Basic / RNDNMGN.ZIP / RNDNMGN.BAS < prev    next >
Encoding:
BASIC Source File  |  1992-01-26  |  4.8 KB  |  112 lines

  1. 10 CLS
  2. 20 PRINT "Do you wish to read documentation before proceeding ? (Y/N) ";
  3. 30 S$ = INKEY$
  4. 40 IF S$ = "" THEN GOTO 30
  5. 50 IF S$ = "y" OR S$ = "Y" THEN GOSUB 740
  6. 60 PRINT
  7. 70 CLEAR
  8. 80 CLS
  9. 90 INPUT "Enter a number to represent bottom of range : ",B
  10. 100 INPUT "Enter a number to represent top of range : ",T
  11. 110 IF T >0 AND B >T THEN GOTO 120 ELSE GOTO 130
  12. 120 PRINT:PRINT "Top of rang must be greater than bottom of range.":GOSUB 1080:GOTO 60
  13. 130 IF T >9999999! THEN GOTO 140 ELSE GOTO 150
  14. 140 PRINT:PRINT "Number entered for top of range is out of processing range.":GOSUB 1080:GOTO 60
  15. 150 IF B >9999999! THEN GOTO 160 ELSE GOTO 170
  16. 160 PRINT:PRINT "Number entered for bottom of range is out of processing range.":GOSUB 1080:GOTO 60
  17. 170 IF T >0 AND B >0 THEN GOTO 200
  18. 180 INPUT "Enter number of digits for output : ",D%
  19. 190 IF T <=0 THEN GOTO 320
  20. 200 IF T >0 THEN GOSUB 570
  21. 210 IF B >0 THEN GOSUB 650
  22. 220 IF T >0 AND D% >E% THEN GOTO 230 ELSE GOTO 250
  23. 230 PRINT:PRINT "Number of digits for output must not excede the number of digits in"
  24. 240 PRINT "the top range entry." :GOSUB 1080:GOTO 60
  25. 250 IF T >0 AND D% =E% THEN GOTO 320
  26. 260 GOSUB 540
  27. 270 M = I*10+1
  28. 280 P = INT(M)
  29. 290 IF T >0 AND P >E% THEN GOTO 250
  30. 300 IF B >0 AND P <L% THEN GOTO 250
  31. 310 D% = P
  32. 320 FOR W = 1 TO D%
  33. 330 GOSUB 540
  34. 340 V = V + (I*10^W)
  35. 350 NEXT W
  36. 360 N = INT(V)
  37. 370 IF B = 0 AND T = 0 THEN GOTO 450
  38. 380 IF N <B THEN GOTO 430
  39. 390 IF T >0 AND N >T THEN GOTO 430
  40. 400 IF N >=B THEN GOTO 410 ELSE GOTO 430
  41. 410 IF T >0 THEN GOTO 420 ELSE GOTO 450
  42. 420 IF N <=T THEN GOTO 450 ELSE GOTO 430
  43. 430 V = 0
  44. 440 GOTO 320
  45. 450 PRINT N
  46. 460 PRINT "Would you like to try another set of numbers ? (Y/N) ";
  47. 470 A$ = INKEY$
  48. 480 IF A$ ="" THEN GOTO 470
  49. 490 IF A$ = "Y" OR A$ ="y" THEN GOTO 60
  50. 500 IF A$ = "N" OR A$ = "n" THEN CLS
  51. 510 PRINT "Controled Random Number Generator by J. Johnson"
  52. 520 PRINT "Copyright 1992 Red Moon Software"
  53. 530 END
  54. 540 RANDOMIZE TIMER
  55. 550 I = RND(X)
  56. 560 RETURN
  57. 570 IF T <=9999999! THEN E% = 7
  58. 580 IF T <=999999! THEN E% = 6
  59. 590 IF T <=99999! THEN E% = 5
  60. 600 IF T <=9999 THEN E% = 4
  61. 610 IF T <=999 THEN E% = 3
  62. 620 IF T <=99 THEN E% = 2
  63. 630 IF T <=9 THEN E% = 1
  64. 640 RETURN
  65. 650 IF B <=9999999! THEN L% = 7
  66. 660 IF B <=999999! THEN L% = 6
  67. 670 IF B <=99999! THEN L% = 5
  68. 680 IF B <=9999 THEN L% = 4
  69. 690 IF B <=999 THEN L% = 3
  70. 700 IF B <=99 THEN L% = 2
  71. 710 IF B <=9 THEN L% = 1
  72. 720 RETURN
  73. 730 PRINT:PRINT:PRINT:PRINT:PRINT
  74. 740 PRINT:PRINT:PRINT:PRINT:PRINT
  75. 750 PRINT "   This program will  generate a random number  defined by your input  to  the"
  76. 760 PRINT " initial  program  prompts.  The first  of which  will  ask you  for a  number"
  77. 770 PRINT " representing the bottom of the user defined range  (lowest number to accept)."
  78. 780 PRINT " The second will ask for a number  to represent the top of the range  (highest"
  79. 790 PRINT " number to accept).  The third will ask  for the number of digits required for"
  80. 800 PRINT " output  (how many digits  do you need ?).  If  you provide  input to both the"
  81. 810 PRINT " first and second prompts, the the third prompt will not appear."
  82. 820 PRINT
  83. 830 PRINT "    You may  wish to skip  one  of the first two prompts  to create a lower or"
  84. 840 PRINT " higher bound to the output.  For instance, if you wanted a three digit number"
  85. 850 PRINT " that is not lower than  25,  then you would answer the first prompt with  25,"
  86. 860 PRINT " leave the second prompt empty (press the ENTER key), and enter 3 to the third"
  87. 870 PRINT " prompt.  If you wanted a  2 digit number that is no higher than 80,  then you"
  88. 880 PRINT " would leave the first prompt empty, enter 80 to the second prompt,  and enter"
  89. 890 PRINT " 2 to the third prompt."
  90. 900 PRINT
  91. 910 PRINT "    To create a  hi/low range  for the  generated number,  just enter  the low"
  92. 920 PRINT " number at the first prompt  and the  high  number  at the  second prompt.  To"
  93. 930 PRINT " create any 5 digit number, leave the first 2 prompts empty and enter 5 to the"
  94. 940 PRINT " the third prompt."
  95. 950 PRINT:GOSUB 1080
  96. 960 PRINT:PRINT : PRINT "Limitations:"
  97. 970 PRINT:PRINT "   - Bottom and Top of range inputs cannot excede 9,999,999."
  98. 980 PRINT:PRINT "   - Top of range value must be higher than the value of the bottom"
  99. 990 PRINT "     range."
  100. 1000 PRINT:PRINT "   - The number of digits required for output cannot excede the"
  101. 1010 PRINT "     number of digits in the top of range value."
  102. 1020 PRINT:PRINT "   - Tight ranges (i.e. bottom range = 3 and top of range = 6) will"
  103. 1030 PRINT "     require a much longer period of time to process than wide ranges"
  104. 1040 PRINT "     (i.e. bottom of range = 120 and top of range =1000).
  105. 1050 PRINT:PRINT:PRINT:PRINT:PRINT:PRINT:PRINT
  106. 1060 PRINT:GOSUB 1080
  107. 1070 RETURN
  108. 1080 PRINT:PRINT "Press any key to continue...";
  109. 1090 S$ = INKEY$
  110. 1100 IF S$ = "" THEN GOTO 1090
  111. 1110 RETURN
  112.