ex.hlp (Topic list)
Important Notice
The pages on this site contain documentation for very old MS-DOS software, purely for historical purposes. If you're looking for up-to-date documentation, particularly for programming, you should not rely on the information found here, as it will be woefully out of date.
RANDOMIZE Statement and RND Function Example
                        Example                Contents  Index  Back
──────────────────────────────────────────────────────────────────────────────
' This example uses the RANDOMIZE statement to seed and reseed the random
' number generator and the RND function to simulate rolling a pair of dice.
 
 RANDOMIZE TIMER             ' Use the timer as seed for the number generator
 DO                          ' Simulate rolling two dice using RND
     D1 = INT(RND * 6) + 1
     D2 = INT(RND * 6) + 1
     CLS                     ' Clear the screen and report the roll
     PRINT "You rolled a"; D1; "and a"; D2; "for a total of"; D1 + D2
     INPUT "Roll again (Y/N)"; Resp$
     PRINT
 LOOP UNTIL UCASE$(MID$(Resp$, 1, 1)) = "N"
 END