RANDOMIZE statement

Syntax

RANDOMIZE (expression)

Description

Use the RANDOMIZE statement with an expression to make the RND function generate the same sequence of random numbers each time the program is run. If no expression is supplied, or if expression evaluates to the null value, the internal time of day is used (the null value is ignored). In these cases the sequence is different each time the program is run.

Example

RANDOMIZE (0)
FOR N=1 TO 10
    PRINT RND(4):' ':
NEXT N
PRINT
*
RANDOMIZE (0)
FOR N=1 TO 10
   PRINT RND(4):' ':
NEXT
PRINT
*
RANDOMIZE (3)
FOR N=1 TO 10   
   PRINT RND(4):' ':
NEXT N
PRINT

This is the program output:

0 2 1 2 0 2 1 2 1 1
0 2 1 2 0 2 1 2 1 1
2 0 1 1 2 1 0 1 2 3