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

For In Statement


The For In statement loops through the properties of an associative array or object. You cannot use it with a nonassociative array. For more information, see About Associative Arrays.

You cannot write code that references a property that is marked with the DONT_ENUM attribute in a For In statement. The DONT_ENUM attribute is a predefined attribute that you cannot modify.

Format

for (LoopVar in object)
{
   statement_block;
}

Table 21 describes the arguments for the For In statement. The statement block runs one time for every element in the associative array or property of the object.

Table 21. Arguments for the For In Statement
Argument
Description

object

An associative array or object:

  • The object must possess at least one defined property.
  • The associative array must possess at least one defined element.

LoopVar

A variable that iterates over every element that resides in the associative array or property of the object.

For each iteration of the loop, the LoopVar argument identifies the name of a property of the object or an element of the array. You can write code that references it with a statement that uses the following format:

  • object[LoopVar]
  • array_name[LoopVar]
Example

The following example creates an object named obj, and then uses the For In statement to read the object properties:

function PropBtn_Click ()
{
   var obj = new Object;
   var propName;
   var msgtext = "";

   obj.number = 32767;
   obj.string = "Welcome to my world";
   obj.date = "April 25, 1945";

   for (propName in obj)
   {
      msgtext = msgtext + "The value of obj." + propName +
         " is " + obj[propName] + ".\n";
   }
   TheApplication().RaiseErrorText(msgtext);
}

Running this code produces the following results:

The value of obj.number is 32767.
The value of obj.string is Welcome to my world.
The value of obj.date is April 25, 1945.

For an example of the For In statement used with an associative array, see About Associative Arrays.

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