Initial values may be given to array elements. For example, if an array is defined as:
integer Answers[4] is 5,17,8,2
the initial values of the elements are 5, 17, 8, and 2. If no values or too few values are given, the uninitialized elements are given the default values:
Element |
Defaults To |
Boolean |
false |
Integer |
0 |
Float |
0.00 |
String |
"" (null) |
If too many values are given, the extra values are dropped. In either case, a warning message is generated when you compile the program.
When ESL initializes an array, it cycles through all the subscripts in the array, changing the last subscript first. Using the example:
integer SalesGraph[2,3] is 1,2,3,4,5,6
the subscripts are cycled through and assigned initial values in the following order:
SalesGraph[1,1] is assigned the value 1
SalesGraph[1,2] is assigned the value 2
SalesGraph[1,3] is assigned the value 3
SalesGraph[2,1] is assigned the value 4
SalesGraph[2,2] is assigned the value 5
SalesGraph[2,3] is assigned the value 6