RANDOM

Use the RANDOM script function to generate random numbers. The generated random number falls within a range that you specify, including the minimum or maximum values themselves.

You can optionally define the initial value that the number generator uses to generate the number set. In this case, the generated number set is always identical: the same numbers are supplied in the same order. The same number set can be accessed if you use this function again.

If you do not specify an initial value, the script function returns a number that continuously varies between the minimum and maximum values that you specify. For a particular initial value, the generated numerical series is always identical: the same numbers are supplied in the same order.

Syntax

RANDOM (Minimum, Maximum[, Basis])

Parameters

Notes:

Examples

The example below shows how to generate a random number between 1 and 10:
:SET &number# = RANDOM(1, 10)

The example below uses a Basis value of 1 as an initial value for generating a number set:
:SET &ret# = RANDOM(&min#, &max#, 1)
:
SET &number# = RANDOM(&min#, &max#)

If you use the function above again, the result will be the same set of values. For the sake of this example, assume that the first ten values of the generated number set are 6, 2, 9, 6, 5, 4, 9, 9, 8 and 2. The result of the first call that is stored in the &number# variable would therefore always be 6.

See also:

seealso

Arithmetic Calculations in Scripts