News

Random Numbers

The aim is to provide a unified way of getting pseudo - random numbers in the different generators. In order to achieve that we created two functions: Random and RSeed ................................

Description
We created the following functions:

number  = Random()
It returns a numeric type value with decimals N(11.9) in the [ 0, 1] rank. The seed may be indicated with the Rseed function. If it is not explicitly initialized before calling the Random function it is automatically initialized with a different value every time the application runs.

number  = RSeed(seed)
It sets the seed used by the Random function in order to generate the random numbers. The seed parameter is of N(10.0) type. It can be set N times and it affects the next Randoms to be executed. The value returned by the function is of numeric type, it is not determined and it is not useful.

Examples
Do While  Condition
...
&SesNro = Random( )
...
Enddo

It generates N pseudo-random numbers. Every time the application is run it generates a different sequence of numbers because the seed always changes.

RSeed( 5 )
Do While  Condition
...
&SesNro = Random( )
...
Enddo

It generates N pseudo-random numbers. Every time the application is run it generates the same sequence of numbers because the seed is always the same one.