Returns a pseudo-random number.
Number := RANDOM(MaxNumber)
- Type: Integer The largest acceptable number. In effect, you are setting a range from one (1) to the number that you specify with the MaxNumber parameter.
Property Value/Return Value
A pseudo-random number between one (1) and the number that you entered for MaxNumber.
If MaxNumber is negative it acts as a positive.
If MaxNumber is zero, this function always returns 1.
A number is always chosen from the same set of numbers. Use RANDOMIZE Function (Integer) to generate a new set of numbers.
This example shows how to generate a pseudo-random number. This example requires that you create the following variables and text constant in the C/AL Globals window. The value of the variable Number2 is positive though the value of MaxNumber is negative and the value of the variable Number3 is always 1 because MaxNumber is 0.
|Text constant name||ENU Value|
Number1 = %1, Number2 = %2, Number3 = %3
x := 100; // x is assigned a positive value. y := -100; // y is assigned a negative value. z := 0; // z is assigned zero. Number1 := RANDOM(x); Number2 := RANDOM(y); Number3 := RANDOM(z); MESSAGE(Text000, Number1, Number2, Number3);