Randomizer?
Root / Programming Questions / [.]
JoshuawlCreated:
To elaborate:
RND returns a random integer in the range of 0 to the argument minus 1. So if you did RND(10) it would pick from 0 to 9. In your case, since you want from 1 to 8, you have to do a bit of math reasoning.
The RNG only picks from 0 up to (but not including) that bound, so to have it start from 1 you just have to add one. However, there's a simple way to figure this out for any range. In your case, you want 1 to 8. 8 - 1 = 7, so 7 will be the highest number we want returned from our RNG. So, we do RND(8)+1. Pretty simple, and the math works for every range you could possibly want.
WHILE #TRUE PRINT RND(8)+1 WENDIf you want a doc that goes into RNG with more detail (including selecting generators and setting seeds) I wrote one.