[an error occurred while processing this directive]
 | Forms Processor Advanced Commands |
Contents
Index of Commands
Search the Forms Processor Docs
rand
Generates a random number for use in Form Processor configuration files.
- $output = rand(n);
-
- $output - A variable in which the random number is placed.
- n - The largest possible number you want rand to return.
- NOTE:
- rand returns a floating point number (1234.567), to use rand effectively, put it in the int function, eg:
$value = int(rand(6))+1;
The +1 is to raise the value from 0 - 5.999 to 1 - 6, see example below for more detail.
- For random numbers, the srand function should be used to randomize the value.
Example:
#Randomize and generate some dice rolls
$Dummy_Value=srand();
$DiceRoll1=int(rand(6))+1;
$DiceRoll2=int(rand(6))+1;
format screen
<HTML>
<HEAD>
<TITLE>Random Numbers - Results of Die Roll</TITLE>
</HEAD>
<BODY>
<H1>Results of Die Roll</H1>
Die one: $DiceRoll1<br>
Die two: $DiceRoll2<br>
</BODY>
</HTML>
.
See also: int(n) function srand(n) function
[an error occurred while processing this directive]