View Full Version : RANDOMIZE[(Numeric_Expression)]
marcuslee
10-09-2008, 17:01
In the help file, Randomize has an optional numeric expression after it. I was wondering what that was for. I tried putting a numeric expression after randomize, and instead of being random, it was the same number over and over again.
Mark ???
ErosOlmi
10-09-2008, 17:08
RANDOMIZE just seeds the random number generator and does not return any random number.
To have random numbers use RND or RNDF functions.
Please post source code having problems and I will check.
Eros
marcuslee
10-09-2008, 18:26
RANDOMIZE just seeds the random number generator and does not return any random number.
To have random numbers use RND or RNDF functions.
I understand, I think. But, what is the opional numeric expression for in the Randomize help file? If it doesn't do anything, then perhaps that doesn't need to be in the help file ... or at least explained what its purpose is.
Please post source code having problems and I will check.
I tried such things as these:
dim x as long
randomize (2)
x = int(rnd(1,10))
msgbox 0, x
dim x as long
randomize (rnd(1,10))
x = int(rnd(1,10))
msgbox 0, x
But, of course, the only one that produced random results ...
dim x as long
randomize
x = int(rnd(1,10))
msgbox 0, x
... was the one that didn't add anything to Randomize. I was just wondering what you could add to it, since the help file tends one to believe that you can add something.
Mark 8)
ErosOlmi
10-09-2008, 18:56
Again mainly info not indicated in thinBasic help.
RANDOMIZE function is based on the one that our compiler gives us. In the help file of our compiler is written:
"number is a seed value that may be any type. If number is not specified, the value returned by the TIMER function is used.
Values returned by the random number generator (RND) depend on an initial seed value. For a given seed value, RND always returns the same sequence of values, yielding a predictable pseudo-random number sequence. Thus, any program that depends on RND will run exactly the same way each time unless a different seed is given."
I missed to write some information in the help file. I will add more info on it. Sorry.
Eros