For Statement
The For statement repeats a series of statements a fixed number of times. Siebel eScript does the following when it runs the For statement:
Evaluates the following expression:
counter = start
Does one of the following:
Condition is true or no conditional expression exists. It does the following work:
Runs the For statement.
Increments the counter.
Goes to For Statement.
Condition is false. It does the following work:
Exits the For statement.
Runs the code line that occurs immediately after the For statement.
Format
for ( [var] counter = start; condition; increment )
{
statement_block;
}
The following table describes the arguments for the For statement.
Argument | Description |
---|---|
counter |
A numeric variable for the loop counter. |
start |
The initial value of the counter. |
Usage
If the counter argument is not declared, then you must use the Var statement to declare it. Although it is declared in the For statement, the scope of the counter variable is local to the entire function that includes the for loop.
If you use multiple counters, then you must use a comma to separate each counter. For example:
for (var i = 1, var j = 3; i < 10; i++, j++)
var result = i * j;
If you configure Siebel CRM to modify the value in the counter argument other than through the increment that occurs as a result of running the For statement, then your script might be difficult to maintain or debug.
Example
For an example of the For statement, see Evaluate Expression Method.