Siebel eScript Language Reference > Statements Reference > Guidelines for Using Siebel eScript >

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:

  1. Evaluates the following expression:

    counter = start

  2. 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 Step 1.
    • 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;
}

Table 20 describes the arguments for the For statement.

Table 20. 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.

Siebel eScript Language Reference Copyright © 2013, Oracle and/or its affiliates. All rights reserved. Legal Notices.