The Random
function generates random numbers within the specified range. There are two implementations of this routine:
Declaration
Result | Float |
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.
Example
The code below demonstrates how to obtain random integer numbers:
DelphiScript
function RandomFunction;
var i, randomValue;
begin
for i := 1 to 10 do
begin
randomValue := Random(100);
Log.Message(IntToStr(randomValue));
end;
end;
See Also
DelphiScript - List of Supported Routines and Variables
Randomize
CreateTempFileName Method