Previous Topic Next topic Print topic


Structure Qualified References

Because the names of structure members (with the exception of the major structure name) can be redeclared or reused within the same block, their scopes overlap. If a member's name has been redeclared within the same block, any reference to that member must be qualified by the name of its containing structure. If the containing structure's name has been redeclared within the same block, it must be qualified, in turn, by the name of its containing structure until an unambiguous reference is created.

A structure qualified reference is a sequence of names written left-to-right in order of increasing level-numbers. The names are separated by periods, and blanks may be written around the periods. The sequence need not include all containing structure names, but it must include sufficient names to make the reference unique. For example:

DECLARE       1  S,
     2          A  FIXED,
     2          B,
     3          A  FLOAT,
     3          C  FLOAT;

In this example, a reference to A is ambiguous because the scope of A FLOAT overlaps the scope of A FIXED. A structure qualified reference to S.A refers to A FIXED. A structure qualified reference to B.A refers to A FLOAT, as does S.B.A.

A structure qualified reference that includes the name of each containing structure from the major structure down to the member is a fully qualified reference. If the name of one or more of the containing structures is omitted, the reference is a partially qualified reference. In the previous example, B.A is a partially qualified reference, and S.B.A is a fully qualified reference, as are S.A, S.B, and S.B.C.

Subscripts can be used anywhere within a structure qualified reference, but it is best to write each set of subscripts immediately following the name that has the corresponding bounds declared for it. For example:

DECLARE     1   S(10),
     2        A    FIXED,
     2        B(3)    FLOAT,
     2        C(3),
     3        D   POINTER;

In the previous example, a reference to S(K).A and a reference to S.A(K) are equivalent, but a reference to S(K).A is preferred. Other recommended references are S(K).B(J) and S(K).C(J).

Previous Topic Next topic Print topic