NET/MASTER Network Control Language (NCL) Reference Manual

RANDOM
Built-in Functions
106126 Tandem Computers Incorporated 4–69
RANDOM The RANDOM built-in function returns a pseudorandom number. The number
returned lies within a range specified in the function.
RANDOM( [
min
] [, [
max
] [,
seed
] ] )
min
specifies the lowest number in the range. The number must be a nonnegative
whole number. The default is 0 (zero).
max
specifies the highest number in the range. The number must be a nonnegative
whole number. The default is 999.
seed
specifies the number to be used to reset the pseudorandom sequence. This must
be a nonnegative whole number. Its default is 0 (zero). To obtain the same
repeatable sequence of random numbers, the same initial number (
seed
) must be
specified for the first and each subsequent call to the RANDOM built-in function.
Considerations
A run-time error results if
min
is not less than
max
.
The magnitude of the range must not exceed 100,000 (that is, if
min
equals 1,
max
must be equal to or smaller than 100001).
The current internal
seed
value for the random number generator is
process-wide. That is, it applies to all procedures that are part of the same process.
Any reasonable method may be used to obtain an initial
seed
. For example, you
can use the TIME built-in function to provide an initial
seed
value.
Examples
In the following example, a random number from 0 (zero) through 999 is returned:
&RESULT = RANDOM()
In the following example, a random number from 0 (zero) through 999 is returned. If
the seed 1993 is used, the number 351 is returned:
&A = 1993
&RESULT = RANDOM(,,&A)