Purpose
Returns a pseudo-random number based on a seed numeric value. The returned random number is greater than zero and less than 1, and has a length of 9 decimal places.
Syntax
►►─┬─ RANDOM-NUMBER ─┬─ ( random-number-seed ) ───────────────────────────────►◄ └─ RANdom ────────┘
Parameters
Specifies the numeric variable data field containing the seed value from which the pseudo-random number is calculated.
Random-number-seed cannot be zero.
Usage
To obtain random numbers:
If the result is set to a fixed value, each execution of the dialog will result in the generation of the same series of pseudo-random numbers.
The result can be moved back to the seed variable by using the result as a redefinition of the seed value, as follows:
03 SEED-VALUE PICTURE 9(9). 03 RESULT-VALUE REDEFINES SEED-VALUE PICTURE V9(9).
Example
In the following example, the random number function is used to generate a sequence of ten pseudo-random numbers:
Field descriptions:
03 SEED-VALUE PICTURE 9(9).
03 RESULT-VALUE REDEFINES SEED-VALUE PICTURE V9(9).
03 RANDOM-TABLE PICTURE V9(9) OCCURS 10 TIMES.
Statements:
MOVE TIME TO SEED-VALUE.
MOVE 1 TO WK-COUNT.
WHILE WK-COUNT LE 10
REPEAT.
MOVE RANDOM(SEED-VALUE) TO RESULT-VALUE.
MOVE RESULT-VALUE TO RANDOM-TABLE(WK-COUNT).
ADD 1 TO WK-COUNT.
END.
|
Copyright © 2014 CA.
All rights reserved.
|
|