Randomize
PowerScript function
Description
Initializes the random number generator so that the Rand function
begins a new series of pseudorandom numbers.
Syntax
|
1 |
Randomize ( n ) |
|
Argument |
Description |
|---|---|
|
n |
The starting value (seed) for the random number generator. |
Return value
Integer. If n is null, Randomize returns null. The return value is
never used.
Usage
The sequence of numbers generated by repeated calls to the Rand
function is a computer-generated pseudorandom sequence. You can use the
Randomize function to initialize the random number generator with a value
from the system clock, or some other changing value, so that the sequence
is always different. For testing purposes, you can select a specific seed
value, which you can reuse to make the pseudorandom sequence repeatable
each time you run the application.
Include Randomize in the script for the Open event in the
application.
Examples
This statement sets the seed for the random number generator to 0 so
that calls to Rand generate a new sequence each time the script is
run:
|
1 |
Randomize(0) |
This statement sets the seed for the random number generator to 4 so
that calls to Rand repeat a specific sequence each time the random number
generator is initialized:
|
1 |
Randomize(4) |
See also