The following example illustrates structure assignment using the BY NAME option:
declare declare declare
1 One, 1 Two, 1 Three,
2 Part1, 2 Part1, 2 Part1,
3 Red, 3 Blue, 3 Red,
3 Orange, 3 Green, 3 Blue,
2 Part2, 3 Red, 3 Brown,
3 Yellow, 2 Part2, 2 Part2,
3 Blue, 3 Brown, 3 Yellow,
3 Green; 3 Yellow; 3 Green;
|
1 2 |
One = Two, by name; One.Part1 = Three.Part1, by name; |
One.Part1.Red = Two.Part1.Red; One.Part2.Yellow = Two.Part2.Yellow;
One.Part1.Red = Three.Part1.Red;
The following example illustrates structure assignment using the BY DIMACROSS option.
dcl
1 x,
2 a fixed bin(31),
2 b fixed bin(31),
2 c fixed bin(31),
2 d fixed bin(31);
dcl 1 xa(17) dimacross like x;
dcl jx fixed bin;
x = 0;
do jx = lboundacross( xa ) to hboundacross( xa );
x = x + xa, by dimacross( jx );
end;
The assignment inside the loop is equivalent to the following statements:
x.a = x.a + xa.a(jx);
x.b = x.b + xa.b(jx);
x.c = x.c + xa.c(jx);
x.d = x.d + xa.d(jx);
dcl
1 x,
2 a fixed bin(31),
2 b fixed bin(31),
2 c fixed bin(31),
2 d fixed bin(31);
dcl 1 xa(17) dimacross like x;
dcl y like x;
x = xa, by dimacross( 1 );
y = xa, by dimacross( 17 );
xa = y, by dimacross( 1 );
xa = x, by dimacross( 17 );