Seeds the random number generator.
RandSeed(iSeed)
Variable | Description |
---|---|
iSeed | The seed value for the random number generator. INTEGER. |
RandSeed uses iSeed as a seed for the random values that all other random functions return.
[-] testcase Rand1() appstate none [ ] INTEGER iSeed = 10 // a random number generation seed [ ] RandSeed(iSeed) [ ] Print(RandInt(0, 100)) [ ] Print(RandInt(0, 100)) [ ] Print(RandInt(0, 100)) [ ] [ ] // Every time Rand1 is executed it returns the same three numbers.
[-] testcase Rand2() appstate none [ ] // NO seed value specified [ ] [ ] Print(RandReal()) [ ] Print(RandInt(1,12)) [ ] [ ] // First run: [ ] // 0.363499 [ ] // 3 [ ] [ ] // Second run: [ ] // 0.369257 [ ] // 11 [ ] [ ] // Third run: [ ] // 0.067510 [ ] // 2
If you do not specify a seed value, the same series of results will occur in each testing session. For example, if you exit and restart Silk Test Classic and then run Rand2 for three consecutive times, you will get the same results as if you would have executed the test three times in the previous testing session.
RandSeed(GetDateTimePart(GetDateTime(), DTP_SECOND))Using this statement before you generate random numbers will yield different results when you run a series of tests in different testing sessions. For example:
[-] testcase Rand3() appstate none [ ] RandSeed(GetDateTimePart(GetDateTime(), DTP_SECOND)) [ ] Print(RandReal()) [ ] Print(RandInt(1,12)) [ ] [ ] // First run: [ ] // 0.754183 [ ] // 6 [ ] [ ] // Second run: [ ] // 0.756977 [ ] // 6 [ ] [ ] // Third run: [ ] // 0.762099 [ ] // 9 [ ] [ ] // Quit Silk Test Classic, restart, then rerun test three times. [ ] [ ] // First run after restarting: [ ] // 0.754649 [ ] // 2 [ ] [ ] // Second run after restarting: [ ] // 0.757908 [ ] // 10 [ ] [ ] // Third run after restarting: [ ] // 0.760702 [ ] // 9