Sent: Saturday, November 11, 2000
19:04
Subject: TIB: randInt on the 89
Hello everybody...here's a routine I came up with for the 89
for generating a random integer between a low and a high integer -- same as
the randInt function on the 86. I hope you find this useful. There is only one
problem -- because I wrote it to work with negative numbers, too (like if you
wanted a number between -5 and 5) it won't work if you use too wide a range of
numbers because the list, l, gets too big. If anybody out there can fix this,
I would greatly appreciate it if you would reply with your solution.
Thanks!
randint(low,high)
Func
Local l,z
seq(x,x,low,high)->l
Lbl getz
iPart(round(10^(dim(string(dim(l)))-1)*rand(),dim(string(dim(l)))-1))->z
If z>dim(l) or z=0:Goto getz
Return l[z]
EndFunc
--Chris