Survey Tabulation > Advanced expressions > 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 these functions: Rnd, RanInt, RanSequence, and Ran.
Syntax
SetRandomSeed([Seed])
Parameters
Seed
Type: Long
Optional. Starting value to use for random number generation. The default is 0.
(return)
Type: Long
New starting value for random number generation.
Remarks
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
Random number functions