Random Function

Applies to TestComplete 14.40, last modified on April 22, 2021

The Random function generates random numbers within the specified range. There are two implementations of this routine:

Declaration

Random()
Result     Float  
Random(iRange) Parameters
iRange [in] Required Integer
Result     Integer  

Description

Returns a random number within the specified range. If the iRange variable is empty, the function generates a float random number within the range from 0 to 1. If the parameter is specified, the function generates a random integer in the range 0..iRange - 1.

Parameters

The function has the following parameter:

iRange

Specifies the right limit of the range defined by the (iRange - 1) expression. A random number is generated within the specified range.

Return Value

A randomly generated value whose type depends on the function implementation:
If iRange is not specified, the return value is a float-type random number. If iRange is specified, the function returns an integer number.

Remarks

To initialize the random number generator, add a single call to Randomize (see Randomize) or assign a value to the RandSeed variable before making any calls to Random. The RandSeed variable holds the initial value for the random number generator. It allows you to generate the same sequences of random numbers.

See Also

DelphiScript - List of Supported Routines and Variables
Randomize

Highlight search results