On Tue, 20 Nov 2001, Nils Raschke wrote:
> The function sysRandom() don�t allow to specify a range or an upper limit
> (the highest possible number is defined in sysRandomMax, but I don�t think I
> should change there anything).

  thats what the function is for, check the API programmer reference:

===
SysRandom
---------
Purpose:    Return a random number anywhere from 0 to sysRandomMax
Prototype:  Int16 SysRandom(Int32 newSeed);
Parameters: newSeed   new seed value, or 0 to use existing seed
Result:     returns a random number.
===

  so...

    val = (SysRandom(0) % 10);  will give a number between 0..9 (inc)

  what gets me is that if it returns a number between 0 and sysRandomMax
  and if sysRandomMax is 32767 - why is it returning an Int16 and not an
  UInt16 :) [something for palm guys to figure out]

> Or, do I have to trim the value that I get from sysRandom() to my needs (if
> so, in what header file I have to look to get the functions to get just the
> first unit (numbers 0-9) of a number)?

  call SysRandom(TimGetTicks()); to initialize the seeding value :)
  its good to use the current ticks, means you'll have a unique random
  pattern every time [theoretically] :)!

  there has also been discussions here about how random SysRandom()
  really is.. you can dig up some archive threads to see the discussion.
  was around 9 to 12 months ago (maybe longer)

// az "argh, get back to work boy [telling self]"
[EMAIL PROTECTED]
http://www.ardiri.com/


--
For information on using the Palm Developer Forums, or to unsubscribe, please see 
http://www.palmos.com/dev/tech/support/forums/

Reply via email to