Siebel eScript Language Reference > Siebel eScript Commands >

Array Objects


An array is a special class of object that holds several values rather than one. You refer to a single value in an array by using an index number or string assigned to that value.

The values contained within an array object are called elements of the array. The index number used to identify an element follows its array name in brackets. Array indices must be either numbers or strings.

Array elements can be of any data type. The elements in an array do not need to be of the same type, and there is no limit to the number of elements an array may have.

The following statements demonstrate how to assign values to an array:

var array = new Array;
array[0] = "fish";
array[1] = "fowl";
array["joe"] = new Rectangle(3,4);
array[foo] = "creeping things"
array[goo + 1] = "and so on."

The variables foo and goo must be either numbers or strings.

Because arrays use a number to identify the data they contain, they provide an easy way to work with sequential data. For example, suppose you want to keep track of how many jellybeans you ate each day, so you could graph your jellybean consumption at the end of the month. Arrays provide an ideal solution for storing such data.

var April = new Array;
April[1] = 233;
April[2] = 344;
April[3] = 155;
April[4] = 32;

Now you have your data stored in one variable. You can find out how many jellybeans you ate on day x by checking the value of April[x]:

for(var x = 1; x < 32; x++)
TheApplication().Trace("On April " + x + " I ate " + April[x] +
   " jellybeans.\n");

Arrays usually start at index [0], not index [1].

NOTE:  Arrays do not have to be continuous. You can have an array with elements at indices 0 and 2 but none at 1.

See Also

The Array Constructor, join() Method, length Property, reverse() Method, sort() Method


 Siebel eScript Language Reference 
 Published: 18 April 2003