Arrays
An array is an n-dimensional collection of elements that have identical attributes.
Only the array itself is given a name. An individual item of an array is referred to by giving its position within the array. You indicate that a name is an array variable by providing the dimension attribute.
Unless specified with REFER, every dimension of every array must have at least one element. When the bounds of an array are specified with REFER, the array can be defined to have zero elements if the following conditions are true:
- The array is never accessed or assigned.
- The array has only one dimension (excluding any inherited dimensions).
- The lower bound of that dimension must be 1.
- All of the elements in the containing structure must be either UNALIGNED or NONVARYING BIT.
So, for example, given the following code, it is valid to allocate
the array
a when n1 is zero if ab3, abc1,
and abc2 are neither accessed nor assigned. dcl n1 fixed bin(31);
dcl p pointer;
dcl
1 a based(p),
2 ab1 fixed bin(31),
2 ab2 fixed bin(31),
2 ab3( n1 refer(ab2) ),
3 abc1 char(40) var,
3 abc2 char(40) var,
2 ab4 char(40) var;