Page 1 of 1

Random function on Mac is different than on Windows

Posted: Sun Mar 24, 2013 8:49 pm
by jack
the Random function in PB for Windows accepts an optional minimum parameter but PB for Mac does not, an oversight?

Re: Random function on Mac is different than on Windows

Posted: Sun Mar 24, 2013 8:55 pm
by wilbert
It seems to work fine when I try it on PB 5.11.

Re: Random function on Mac is different than on Windows

Posted: Sun Mar 24, 2013 11:22 pm
by jack
I was using version 5.0, not too crazy about the changes in versions 5.10+ but will give it a try.
[edit] it works in version 5.11 [/edit]

Re: Random function on Mac is different than on Windows

Posted: Mon Mar 25, 2013 6:36 am
by wilbert
The optional parameter was added in version 5.10 so that explains the problems you had.

Re: Random function on Mac is different than on Windows

Posted: Mon Mar 25, 2013 7:16 am
by J. Baker
You can use the following in v5.0...

Code: Select all

Procedure RandomRange(FromRange, ToRange)
 Range = ToRange - FromRange
  RandomRange = FromRange + Random(Range)
 ProcedureReturn RandomRange
EndProcedure

Loop = 0

Repeat
 
Loop +1 
 
RR = RandomRange(15, 30)

Debug RR

Until Loop = 10

Re: Random function on Mac is different than on Windows

Posted: Mon Mar 25, 2013 8:29 pm
by jack
thank you J. Baker :)