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 value is 0.
(return)
Type: Long
Random value >= 0 and <= 2147483647.
Notes
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 uses 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 resets 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