Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Random Generator
Message
From
22/01/2001 22:52:53
 
 
To
22/01/2001 22:46:49
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
00467103
Message ID:
00467111
Views:
16
>Why don't I have to reset the RAND() after each call?
>The manual says:
>'RAND( ) returns the same sequence of random numbers if you use the same seed value for nSeedValue the first time you issue RAND( ) followed by subsequent RAND( ) function calls without nSeedValue.'

That works like this:
* Set the seed for all subsequent Rand() without a seed
?rand(1) && 03
?rand()  && 25
?rand()  && 71
?rand()  && 48

* Now reset the seed
?rand(2) && 05
?rand()  && 06
?rand()  && 62
?rand()  && 36

* Now go back to the orginal seed
?rand(1) && 03
?rand()  && 25
?rand()  && 71
?rand()  && 48
THat code generates teh same out put no matter when you run it. The seed only needs to be set once, and thats at the beginning of the app, where you can do Rand(-1) which sets the seed based on the time.
Previous
Reply
Map
View

Click here to load this message in the networking platform