In order to make random numbers 'appear' random, you need to seed the random number generator by using the
Randomize command.
This command initializes the internal random number generator, so that subsequence polls of the RND() function, will return values from this particular seeded sequence. So setting a particular seed, will generate the same sequence, time in, time out. This can useful when you need it, but annoying when you don't
. An good example of this being a useful feature, would be using fractals to generate terrains/texture maps. As when seeded with the same random sequence, you'll get the same terrain every time.
Anyway, In order to make it appear random, you need to Seed the generator with some value from the computer that is constantly changing, so it won't be the same each time the program code is compiled & executed. For this, we use the
TIMER() function. The Timer() function returns the current millisecond, taken from when the computer was last started. There are 1000 milliseconds per second, so this valid is changing rapidly, making it perfect way to seed our random number generator.
So long story short, by adding this line of code '
Randomize Timer()' to the start of your code, will ensure that the random sequence is different each time.
Kevin Picone
[url]www.underwaredesign.com[/url]
Play Nice!
Play Basic (Release V1.073 Out Now)