Returns a random float in the range low (exclusive) to high (exclusive).
Detailed Discussion
The random module provides functions to generate random numbers.
Print Rnd() ' anything between 0.0 and 1.0 Print Int(Rnd(10)) ' any integer from 0 to 9 Print Int(Rnd(5,10)) ' any integer from 5 to 9 Print (Int(Rnd(21))-10) ' any integer from -10 to 10
The current random number generator seed used by Rnd.
A common way to initialize seed is to use the current system time, so the random number generator always generates different sequences after every start up:
Local date := GetDate() Seed = date[3] * 3600000 + date[4] * 60000 + date[5] * 1000 + date[6]
Returns a random float in the range low (exclusive) to high (exclusive).
Print Rnd(5,10) ' anything between 5.0 and 10.0 Print Int(Rnd(5,10)) ' any integer from 5 to 9
Attention: When trying to generate integers around 0, don't write Int(Rnd(-10,10))! Because all numbers between -1.0 and +1.0 will get cast to 0, doubling the chance for a 0. Instead, write:
Print (Int(Rnd(21))-10) ' any integer (from 0 to 20)-10 = from -10 to 10