RandomRange()

Share your advanced PureBasic knowledge/code with the community.
User avatar
J. Baker
Addict
Addict
Posts: 2185
Joined: Sun Apr 27, 2003 8:12 am
Location: USA
Contact:

RandomRange()

Post by J. Baker »

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.
c4s
Addict
Addict
Posts: 1981
Joined: Thu Nov 01, 2007 5:37 pm
Location: Germany

Re: RandomRange()

Post by c4s »

Using Macro:

Code: Select all

Macro RandomRange(Min, Max)
	((Max) - Random((Max) - (Min)))
EndMacro
If any of you native English speakers have any suggestions for the above text, please let me know (via PM). Thanks!
User avatar
J. Baker
Addict
Addict
Posts: 2185
Joined: Sun Apr 27, 2003 8:12 am
Location: USA
Contact:

Re: RandomRange()

Post by J. Baker »

c4s wrote:Using Macro:

Code: Select all

Macro RandomRange(Min, Max)
	((Max) - Random((Max) - (Min)))
EndMacro
Nice! ;)
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.
Post Reply