Bearbeiten

Freigeben über


System.Randomize([Integer]) Method

Version: Available or changed with runtime version 1.0.

Generates a set of random numbers from which the RANDOM method (Integer) will select a random number.

Syntax

 System.Randomize([Seed: Integer])

Note

This method can be invoked without specifying the data type name.

Parameters

[Optional] Seed
 Type: Integer
A number used to create a unique set of numbers.

Remarks

If you use the same number as Seed, the same set of numbers is generated. If you omit this optional parameter, Randomize uses the current system time (total number of milliseconds since midnight). Calling the Randomize method before the Random Method makes the random numbers more unpredictable.

Furthermore, the random generator is specific to each connection so the sequence of numbers that is returned when you call the Random Method will be the same after each call to Randomize with a specific seed.

Example

The following example generates random numbers between 1 and 5 by using the Seed from the Randomize method to initialize the random number generator in the Random Method. The Randomize method uses the data from system clock as the Seed value.

var
    x: Integer;
    Text000: Label 'X=%1';
begin
    Randomize();  
    x := Random(5);  
    Message(Text000, x);  
end;

System Data Type
Get Started with AL
Developing Extensions