Random function on Mac is different than on Windows

Everything else that doesn't fall into one of the other PB categories.
jack
Addict
Addict
Posts: 1359
Joined: Fri Apr 25, 2003 11:10 pm

Random function on Mac is different than on Windows

Post by jack »

the Random function in PB for Windows accepts an optional minimum parameter but PB for Mac does not, an oversight?
wilbert
PureBasic Expert
PureBasic Expert
Posts: 3944
Joined: Sun Aug 08, 2004 5:21 am
Location: Netherlands

Re: Random function on Mac is different than on Windows

Post by wilbert »

It seems to work fine when I try it on PB 5.11.
Windows (x64)
Raspberry Pi OS (Arm64)
jack
Addict
Addict
Posts: 1359
Joined: Fri Apr 25, 2003 11:10 pm

Re: Random function on Mac is different than on Windows

Post 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]
wilbert
PureBasic Expert
PureBasic Expert
Posts: 3944
Joined: Sun Aug 08, 2004 5:21 am
Location: Netherlands

Re: Random function on Mac is different than on Windows

Post by wilbert »

The optional parameter was added in version 5.10 so that explains the problems you had.
Windows (x64)
Raspberry Pi OS (Arm64)
User avatar
J. Baker
Addict
Addict
Posts: 2196
Joined: Sun Apr 27, 2003 8:12 am
Location: USA
Contact:

Re: Random function on Mac is different than on Windows

Post 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
www.posemotion.com

PureBasic Tools for OS X: PureMonitor, plist Tool, Data Maker & App Chef


Even the vine knows it surroundings but the man with eyes does not.
jack
Addict
Addict
Posts: 1359
Joined: Fri Apr 25, 2003 11:10 pm

Re: Random function on Mac is different than on Windows

Post by jack »

thank you J. Baker :)
Post Reply