Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Rand()
Message
 
 
To
09/09/2005 10:38:53
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Title:
Re: Rand()
Environment versions
Visual FoxPro:
VFP 9
OS:
Windows XP SP2
Network:
Windows 2000 Server
Database:
Visual FoxPro
Miscellaneous
Thread ID:
01048125
Message ID:
01048164
Views:
17
Grady,

You only call rand() with an argument one time, to seed the pseudorandom number generator chain, all subsequent calls should be without an argument.

Ideally the seed number should be a large prime number in order to create a decent set of random numbers.

The fact that using the same seed will give you the same chain is a good thing because it allows repeatability in your tests. This way you can make a run, examine the output, change the code, make another run and compare the two outputs.

It's an annoyance though when you want to generate different chains, so the -1 seed can be used so that different runs will produce different results.

>I'm searching for a code snippet that will create random numbers within a defined range. I've been tinkering with rand() but it seems to always come up with the same random number based on what is in the braces. That's great if you only want one random number, but I need to be able to set the number of numbers and the range of those numbers.
df (was a 10 time MVP)

df FoxPro website
FoxPro Wiki site online, editable knowledgebase
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform