RANDOMIZE - Initialize the random number generator

Language reference ›› Built-in procedures ›› Miscellaneous ››
Parent Previous Next

RANDOMIZE(<expression>)


NEW! (V2.1):  Initialize the random number generator.


The random number generator gives always the same sequence of numbers at each processor reset.

Calling the RANDOMIZE procedure with some dynamic data may change this behavior.

The argument may be a constant or some kind of data that may be different at each run, like ADC values, TMRx counters, ...

Due to the generator algorithm, the value cannot be zero, so if the given value is zero, 1 is taken instead; RANDOMIZE(0) is equivalent to RANDOMIZE(1).


<expression> is any BYTE, WORD or LONGWORD expression.


Note: The internal random number generator's data are always initialized at startup, so if the initialized size given by the function RANDOMIZE() is less than the the one used in further uses of the RANDOM() function, the coherency is always maintained.



See also: RANDOM.