Developer Documentation Library > UNICOM Intelligence Function Library > Random number functions > SetRandomSeed
 
SetRandomSeed
This function sets the starting point for the random number generator. This is stored by the mrScript engine and Evaluate component and passed to the Rnd, RanInt, RanSequence, and Ran functions.
Syntax
SetRandomSeed([<seed>])
Parameters
<seed>
Type: Long
(Optional.) Starting value to use for random number generation. The default value is 0.
(return)
Type: Long
New starting value for random number generation.
Notes
<seed> can be any Long value, positive, zero, or negative. If <seed> is omitted, an unpredictable random value is returned. This function can therefore be used for generating true random numbers, unlike RanInt and Rnd, which return reproducible sequences of values.
Example
This example SQL query shows using SetRandomSeed with and without the <seed> parameter.
SELECT Serial,
SetRandomSeed() AS Seed1,
SetRandomSeed(3) AS Seed2
FROM vdata
Here is the result set for the first five records. Each time you run this query, the results in the Seed1 column will be different because new random values are generated:
Serial Seed1 Seed2
------ ----------- -----
1 -1272667498 3
2 1402978284 3
3 -1930756257 3
4 -887407040 3
5 -456506117 3
See also
Rnd
Random number functions