qp.hlp (Table of Contents; Topic list)
Important Notice
The pages on this site contain documentation for very old MS-DOS software, purely for historical purposes. If you're looking for up-to-date documentation, particularly for programming, you should not rely on the information found here, as it will be woefully out of date.
Random Function
  ◄Summary► ◄Details► ◄Example►                                   ◄Back►
 
  Argument
 
    limit    Optional; a positive integer expression representing the
             upper limit of a range for random values
 
  Returns
 
    Real     If no argument is passed, a real number in the range
             0 <= returnvalue < 1
 
    Word     If a limit is passed, a whole number in the range
             0 <= returnvalue < limit
 
  Description
 
    The Random function is a pseudorandom-number generator. Each call
    to Random returns one number. If no argument is passed, Random
    returns a real number greater than or equal to 0 but less than
    1. If a limit argument is passed, Random returns a word
    containing an integer greater than or equal to 0 but less than
    the limit. If a limit of 1 is passed, Random returns 0.
 
    Random takes a starting value from RandSeed, defined in the System
    unit, and produces a sequence of numbers. Each call to Random
    returns one number and sets RandSeed to a new value. If RandSeed is
    not initialized to some value before the first call to Random,
    Random generates a predictable sequence based on RandSeed's initial
    value of 0.
 
    Initialize RandSeed to an unpredictable value by a call to the
    Randomize procedure or to a specified value by an assignment to
    RandSeed. Random always generates the same number sequence when a
    given starting value is in RandSeed. To reproduce a known random
    series previously generated by Random, set RandSeed to the known
    starting value.