Please enable JavaScript to view this site.

ESL Documentation

Definition and Reference

Define or reference an array.

[global] {string|integer|float|boolean} [variable|constant]

{ ARR_NAME[N]

| ARR_NAME[N1, N2, ...]

| ARR_NAME[N thru N, N thru N ...]

| ARR_NAME[N thru N] }

[is VAR1 [,VAR2 [,VAR3] ] ...]

 

global

Define a global variable array.

 

ARR_NAME

The identifier for the variable or constant array. Note that you must include the square brackets ([ ]) shown in the model when you define an array.

 

N

An integer value representing the number of elements in the array, starting with 1 and ending with N.

 

N1, N2, ...

Integer values representing the number of elements for each dimension of the array, starting with 1 and ending with N1, N2, ... respectively. The number of dimensions must not exceed 11.

 

N thru N

Integer values representing the beginning and ending integers used to reference the elements.

 

is VAR1,VAR2 ...

Integer, floating point, string, or boolean values representing the initial values of the array elements. If you specify too many initial values, the extra values are dropped. If you specify too few initial values, ESL uses the following defaults to fill the remainder of the array:

Element Default Initialization

boolean false

integer 0

float 0.00

string ""

In both cases, a warning is generated. When ESL initializes an array, it cycles through all the subscripts in the array reference, varying the last dimension's subscript first.

Description

An array is a group of variables or constants, all accessed by the same name but with different subscripts. An array element is used like a regular string, integer, float, or boolean variable or constant, except that an array element cannot be appended to.

When defining an array, you must specify the data type, the array name, and the range of permissible elements (subscripts) of the array. The subscripts for arrays are always surrounded by brackets. The maximum number of elements per array depends on the type of array, as follows:

Type Limit

integers, strings 500 million

floats 250 million

booleans 2 gigabytes

An array can contain up to 11 dimensions. The number of elements per dimension is unlimited as long as the total size does not exceed the limits shown in this table. Only the first dimension can be resized, using the resize action statement.

Note that you cannot pass array variables to ESL subroutines.

When global arrays are loaded from global space into program space for an ESL program that is executed by a change to program statement, the new number of dimensions is not checked against the number of dimensions defined for the array in the original program. Therefore, if the number of elements for any dimension, or the number of dimensions of the array in the new program, is different from what was defined in the original program, the results are unpredictable.

If the program is compiled with External Strings, then the initial value of string arrays will be externalized.

Referencing an Array

When referencing a variable array, [N] is the subscript that references an array element, and does not designate the range of permissible elements (subscripts) as it did when you defined it.

Example

global integer Profits_IV[5]

global string Sales_SV[2,3] is # Sales[1,2] = "DC"

"CT","DC","NY","BC","SF","LA" # Sales[2,1] = "BC"

integer Bar[0 thru 2,10 thru 12] is

2,3,3,Var_A,15,(5*Var_A),5,3,1228

# These two copy statements use array references:

copy Data_IV[2,2] to Accumulate

copy Sales_SV[Person_IV,Region_IV] to City

See Also

resize Action Statement