The LIKE attribute specifies that the name being declared has an organization that is logically the same as the referenced structure or union (object of the LIKE attribute). The object variable’s member names and their attributes, including the dimension attribute, are effectively copied and become members of the name being declared. If necessary, the level-numbers of the copied members are automatically adjusted. The object variable name and its attributes, including the dimension attribute, are ignored.
|
The objects in all LIKE attributes are associated with declared names before any LIKE attributes are expanded.
New members cannot be added to the created structure or union. Any level-number that immediately follows the object variable in the LIKE attribute must be equal to or less than the level-number of the name with the LIKE attribute.
The following declarations yield the same structure for X.
dcl
1 A(10) aligned static,
2 B bit(4),
2 C bit(4),
1 X like A;
dcl
1 X,
2 B bit(4),
2 C bit(4);
Notice that the dimension (DIM(10)), ALIGNED, and STATIC attributes are not copied as part of the LIKE expansion.
The LIKE attribute is expanded before the defaults are applied and before the ALIGNED and UNALIGNED attributes are applied to the contained elements of the LIKE object variable.