Siebel eScript Language Reference > Siebel eScript Language Overview > Siebel eScript Statements >
The for...in statement loops through the properties of an associative array or object.
NOTE: The for...in statement can be used with associative arrays, which are arrays that use strings as index elements. The for...in statement is not for use with non-associative arrays. For more information, read Associative Arrays in Siebel eScript.
for (LoopVar in object)
A previously defined associative array or object
A variable that iterates over every element in the associative array or property of the object
NOTE: An object must have at least one defined property or it cannot be used in a for...in statement. Associative arrays must have at least one defined element.
When using the for ... in statement in this way, the statement block executes one time for every element in the associative array or property of the object. For each iteration of the loop, the variable LoopVar contains the name of one of the elements of the array or properties of object, and may be accessed with a statement of the form
NOTE: Properties that have been marked with the DONT_ENUM attribute are not accessible to a for...in statement.
This example creates an object called
obj, and then uses the for...in statement to read the object's properties.
function PropBtn_Click ()
var obj = new Object;
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";
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, read Associative Arrays in Siebel eScript.