RanInt
This function returns a random integer number. The numbers generated by this function are not true random numbers because they can be reproduced. However, the numbers generated meet general statistical standards of randomness.
Syntax
RanInt([Seed])
Parameters
Seed
Type: Long
The starting point to be used for generating the random number. The default is 0.
(return)
Type: Long
Random value >= 0 and <= 2147483647.
Remarks
The maximum possible value, 2147483647, is 2^31 – 1, because a Long value has 31 bits available (for non-negative numbers).
If
Seed is supplied, it is used to reset the starting point for the random number generator, as in
SetRandomSeed, before the random number is generated.
If Seed is not supplied or has a value of 0, the function will use the starting point stored for the random number generator by the mrScriptBasic engine or Evaluate component and passed as a hidden parameter.
Each time you call one of the randomization functions, the starting point stored for the random number generator is updated. This means that if you call the function repeatedly without specifying the Seed parameter, the sequence of results is determined by the changing value passed as a hidden parameter. Specifying the Seed parameter is a way of resetting this sequence.
Example
This mrScriptBasic example uses the RanInt function to populate an array with random integers.
Dim i, random[10]
For i = 0 To 9
random[i] = RanInt()
Next
Here are the output values:
1045025264
848909463
43370521
73429201
1057695229
19335566
609059656
695910923
413457467
28422312
See also