[ ] Array reference
- Last Updated: January 21, 2026
- 2 minute read
- OpenEdge
- Version 12.8
- Documentation
Square brackets ([ ]) enclose array subscripts ([1],
[2], etc.), initial values (such as [1,2,3,4]), or
ranges (such as, [1 FOR 4]). The following sections describe these uses in
more detail.
Array subscripts
In ABL, the first element of the array has an index value of 1. The following example shows
how to reference array elements using a subscript:
|
Initial values
The notation
[n,n,n...] is only allowed for the INITIAL
value in a DEFINE VARIABLE statement or during the initialization of the variable
in the VAR statement, as shown in the following example:
|
If you need to assign the elements in the array outside of those two statements, you have
to do it one at a time, if the values are different. For example:
|
However, if the value is the same for all elements, you can just assign the one value to
the array:
|
Ranges
The range notation
In the example, the
[n FOR m] causes
ABL to start with the nth array element and to work with that and the
next m elements. In a range, you can use a variable for the first
element, but the second element must be a constant. The range notation can be used in a
statement where array elements are expanded automatically, such as DISPLAY,
UPDATE, SET, EXPORT, and
IMPORT. The following example shows how to use a range in a
DISPLAY statement:
|
DISPLAY statement expands to
DISPLAY myArray[1] myArray[2] myArray[3] myArray[4].