Bookshelf Home | Contents | Index | Search | PDF |
Siebel eScript Language Reference > Siebel eScript Language Overview > eScript Statements >
for Statement
The for statement repeats a series of statements a fixed number of times.
Syntax
for ( [var] counter = start; condition; increment )
{
statement_block;
}
Returns
Not applicable
Usage
The counter variable must be declared with var if it has not already been declared. If it is declared in the for statement, its scope is local to the loop.
First, the expression
counter = start
is evaluated. Then condition is evaluated. If condition is true or if there is no conditional expression, the statement is executed. Then the increment is executed and condition is reevaluated, which begins the loop again. If the expression is false, the statement is not executed, and the program continues with the next line of code after the statement.
Within the loop, the value of counter should not be changed, because changing the counter makes your script difficult to maintain and debug.
A for statement can control multiple nested loops. The various counter variables and their increments must be separated by commas. For example:
for (var i = 1, var j = 3; i < 10; i++, j++)
var result = i * j;Example
For an example of the for statement, read eval() Method.
See Also
Bookshelf Home | Contents | Index | Search | PDF |
Siebel eScript Language Reference Published: 18 April 2003 |