There's nothing wrong with RND() but if you don't use RANDOMIZE TIMER() the program can sometimes pick exactly the same random numbers every time it's ran.
If you use the same seed it produces the same numbers which are perfect for encryption/decryption routines. Not so good for making something you want to be "random" every time.
Run this at least twice:
` Use a specific seed for random numbers or use timer() instead of a number for better random numbers
randomize 2830
` Check if this is the second time this has been ran
if file exist("RandomTest.txt")
` Open the old file
open to read 1,"RandomTest.txt"
print "Old Loaded Data:"
print ""
` Read the 10 old numbers
for t=1 to 10
` Read the data
read string 1,a$
` Show the old data
print "Random Number "+str$(t)+": "+a$
next t
print ""
close file 1
` Delete the file
delete file "RandomTest.txt"
endif
open to write 1,"RandomTest.txt"
print "New Data:"
print ""
` Make 10 random numbers
for t=1 to 10
` Pick a random number
a=rnd(100)
` Write the random number to the file
write string 1,str$(a)
` Show the new number
print "Random Number "+str$(t)+": "+str$(a)
next t
close file 1
print ""
print "Now if this has been ran more than once you should see the same numbers."
wait key
If you run this program twice (without changing the seed number) in a row, tomorrow, a week from now, or in several years from now it'll still produce the same "random" numbers every time.
And since the TIMER() is a number that started counting up from the minute you turned on your computer... every time it sees RANDOMIZE TIMER() it uses a different seed. The TIMER() is always going up while the computer is on... even if you're not running a Darkbasic program it's still going up.
So that's why we use it... to guarantee that our programs will produce more random numbers every time somebody runs it.