Progress
Language Reference


RANDOM Function

Interfaces
OS
SpeedScript
All
All
Yes

Returns a random integer between two integers (inclusive). The Random Number Generator (-rand) parameter determines whether the same sequence of random numbers is generated for each session. For information on this parameter, see the Progress Startup Command and Parameter Reference.

SYNTAX

RANDOM ( low , high ) 

low

An integer expression that is the lower of the two expressions you are supplying to the RANDOM function.

high

An integer expression that is the higher of the two expressions you are supplying to the RANDOM function.

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 order-lines for each order record.

r-random.p
DEFINE VARIABLE onum AS INTEGER.
DEFINE VARIABLE olnum AS INTEGER.

DO onum = 1 TO 10 TRANSACTION:
    CREATE order.
    order.order-num = onum.
    order.order-date = TODAY.
    DO olnum = 1 TO RANDOM(1,9):
        CREATE order-line.
        order-line.line-num = olnum.
        order-line.item-num = olnum.
    END.
END. 


Copyright © 2004 Progress Software Corporation
www.progress.com
Voice: (781) 280-4000
Fax: (781) 280-4095