Specifying the dimension attribute on a structure or union results in an array of structures or an array of unions, respectively. The elements of such an array are structures or unions having identical names, levels, and members. For example, if a structure were used to hold meteorological data for each month of the year for the twentieth and the twenty-first centuries, it might be declared as follows:
Declare 1 Year(1901:2100),
3 Month(12),
5 Temperature,
7 High decimal fixed(4,1),
7 Low decimal fixed(4,1),
5 Wind_velocity,
7 High decimal fixed(3),
7 Low decimal fixed(3),
5 Precipitation,
7 Total decimal fixed(3,1),
7 Average decimal fixed(3,1),
3 * char(0);
You could refer to the weather data for July 1991 by specifying Year(1991,7). Portions of this data could be referred to by Temperature(1991,7) and Wind_Velocity(1991,7). Precipitation.Total(1991,7) or Total(1991,7) would both refer to the total precipitation during July 1991.
Temperature.High(1991,3), which would refer to the high temperature in March 1991, is a subscripted qualified reference.
The need for subscripted qualified references becomes apparent when an array of structures or unions contains members that are arrays. In the following example, both A and B are structures:
declare 1 A (2,2),
(2 B (2),
3 C,
3 D,
2 E) fixed bin;To refer to a data item, it might be necessary to use as many as three names and three subscripts. For example:
As long as the order of subscripts remains unchanged, subscripts in such references can be moved to names at a lower or higher level. In the previous example, A.B.C(1,1,2) and A(1,1,2).B.C have the same meaning as A(1,1).B(2).C for the above array of structures. Unless all of the subscripts are moved to the lowest level, the reference is said to have interleaved subscripts, so A.B(1,1,2).C has interleaved subscripts.
Any item declared within an array of structures or unions inherits dimensions declared in the parent. In the previous declaration for the array of structures A, the array B is a three-dimensional structure, because it inherits the two dimensions declared for A. If B is unique and requires no qualification, any reference to a particular B would require three subscripts, two to identify the specific A and one to identify the specific B within that A.