PreviousNextIndex

RANDOM function

Returns a random INTEGER value between two integers (inclusive).

Note: This function returns a number from a pseudorandom sequence of numbers rather than a truly random sequence.

The Alternate Random Number Generator (-rand) parameter determines whether the same sequence of random numbers is generated for each session. For information on this parameter, see OpenEdge Deployment: Startup Command and Parameter Reference.

Syntax

RANDOM ( low , high ) 

low
high
Example

Often when you set up a database for testing purposes, you want to generate many records without actually keying in data for each record. The r-random.p procedure generates 10 Order records and a random number of OrderLines for each Order record.

r-random.p
DEFINE VARIABLE onum  AS INTEGER NO-UNDO. 
DEFINE VARIABLE olnum AS INTEGER NO-UNDO. 
DO onum = 1 TO 10 TRANSACTION: 
  CREATE Order. 
  ASSIGN 
    Order.OrderNum  = onum 
    Order.OrderDate = TODAY. 
  DO olnum = 1 TO RANDOM(1,9): 
    CREATE OrderLine. 
    ASSIGN 
      OrderLine.LineNum = olnum 
      OrderLine.ItemNum = olnum. 
  END. 
END. 


OpenEdge Release 10.2B
Copyright © 2009 Progress Software Corporation
PreviousNextIndex