UTIL_Rand

function

Library: Utilities (OMUTIL legacy)
Include: omutil.xin

Returns: A pseudo-random number between 0 and UTIL_RAND_MAX.


Declaration
define external integer function UTIL_Rand


Purpose

This function returns a pseudo-random number between 0 and UTIL_RAND_MAX (32767).

Example:

  ; In this example, the time is used as a seed to generate a random number. The output shows the random number
  ; UTIL_Srand is a function that needs to be called to generate the seed for UTIL_Rand.
  
  include "omutil.xin"
  process
  
     local integer seed initial {0}
     local integer RandomNumber initial {0}
  
     set seed to UTIL_GetMilliSecondTimer
     UTIL_Srand(seed)   ; sets the seed
  
     set RandomNumber to UTIL_Rand
     output "Random Number = " || "d" % RandomNumber