Retro video games delivered to your door every month!
Click above to get retro games delivered to your door ever month!
X-Hacker.org- Force 4.0 Reference - random() return a random number between 0 and 32767 http://www.X-Hacker.org [<<Previous Entry] [^^Up^^] [Next Entry>>] [Menu] [About The Guide]
 random()            Return a random number between 0 and 32767
------------------------------------------------------------------------------
 Declaration
   math.hdr

 Syntax
   func uint random extern
   param value uint uSeed

 Arguments
   uSeed is an arbitrary number to use as the seed in random number
   generation.

 Return
   A random number between 0 and 32767.

 Description
   The random() function returns a randomly generated number between 0 and
   32767 based upon a seed. Call the random() function once with a seed number
   to initialize a sequence of random digits. All subsequent calls with
   uSeed set to 0 return a sequence of digits.

 Example
   #define EXAMPLE_MATH
   #include example.hdr

   proc Test_random
   vardef
      uint nRandom
      uint n
   enddef
   random( ival( substr( time(), 7, 2 ) ) ) // initialize random generator
   for n := 1 to 10
      ? random( 0 )                         // generate ten random numbers
   next
   endproc

   proc main
   Test_random()
   endproc

See Also: randomize() randomnum()

Online resources provided by: http://www.X-Hacker.org --- NG 2 HTML conversion by Dave Pearson