INDFOR attribute
The INDFOR attribute specifies that the name that is declared has an organization that is logically the same as the referenced structure or union, the object of the INDFOR attribute. The INDFOR attribute is similar to the LIKE attribute.
The member names and their attributes, excluding the dimension attribute, of the object variable are effectively converted to FIXED BIN(15) and become members of the name that is declared. This differs from the LIKE attribute, which copies the attributes.
- object-variable
- Can be a major structure, a minor structure, or a union. It must
be known in the block that has the INDFOR attribute. It can be qualified
but must not be subscripted. The object or its members can also have
the INDFOR attribute if they were declared previously.
The objects in all INDFOR attributes are associated with declared names before any INDFOR attributes are expanded.
The INDFOR attribute is expanded before the defaults are applied and before the ALIGNED and UNALIGNED attributes are applied to the contained elements of the INDFOR object variable. However, the INDFOR attribute is expanded only after all INDFOR attributes have been resolved.
Example
This example illustrates the difference between the INDFOR attribute and the LIKE attribute.
This example is based on the following declaration:
dcl 1 a, 2 b char(8), 2 c fixed dec(5,0);Note how the following declarations are expanded.
| Given declaration statement | Expanded to |
|---|---|
dcl 1 alike like a; |
dcl 1 alike, 2 b char(8), 2 c fixed
dec(5,0); |
dcl 1 aindfor indfor a; |
dcl 1 a, 2 b fixed bin(15), 2 c fixed
bin(15); |
