Directives
RANDOMIZE Set Random Ke y
 
Format RANDOMIZE seed
 
Where:
 
seed Numeric value or expression to be used as the seed by the random number generator.
 
Description Use the RANDOMIZE directive to assign a seed to be used by the random number generator. ProvideX uses the given value to define the starting point for the random number generator (system variable RND). Use the RANDOMIZE directive to have ProvideX return a repeatable random sequence.
 
See Also RND System Variable
RND( ) Function.
 
Example In the following example, ProvideX will RANDOMIZE 1, or create a repeatable random sequence using 1 as the seed. Then, for instance, each time the number 2 is encountered in the loop below, it will generate 0.59859266.
 
1000 FOR I=1 TO 2
1010 RANDOMIZE 1
1020 FOR J=1 TO 5
1030 PRINT RND," ",
1040 NEXT J
1050 PRINT "END OF LOOP ",STR(I)
1060 NEXT I
-:run
0.11337858 0.59859266 0.81950925 0.76559375 0.5199119 END OF LOOP 1
0.11337858 0.59859266 0.81950925 0.76559375 0.5199119 END OF LOOP 2
In the example below, ProvideX will use a repeatable random sequence for indices; i.e., to create a repeatable number to use each time a particular index number is encountered.
 
0010 INPUT "Enter random seed:",N
0020 RANDOMIZE N
0030 OPEN (31)"TESTFILE"
0040 FOR I=1 TO 1000
0050 READ (31,IND=INT(RND*100),ERR=0090)R$
0060 PRINT RND," ",R$," ",
0070 NEXT I
0080 PRINT "DONE"; CLOSE (31); STOP
0090 ...