Barbara,
If I found that a predecessor had coded a ds like that with a mixture of
relatively-positioned and specifically-positioned subfields, I would
feel obliged to hunt them down and put them out of their misery! It
would be SO easy to misinterpret that code. :-)
Trevor Briggs
Analyst/Programmer
Lincare, Inc.
(727) 431-1246
TBriggs2@xxxxxxxxxxx
-----Original Message-----
From: rpg400-l-bounces@xxxxxxxxxxxx
[mailto:rpg400-l-bounces@xxxxxxxxxxxx] On Behalf Of Barbara Morris
Sent: Wednesday, June 19, 2013 6:12 PM
To: rpg400-l@xxxxxxxxxxxx
Subject: Re: Data structure overlay *next failure
On 6/19/2013 12:37 PM, Brian May wrote:
I don't think you are quite getting what *NEXT does.
In your example, I assume you are wanting the carr array to overlay c1
through c12. But that is not what you told it to do. You told it to
overlay the data structure starting immediately after the last subfield
defined for the structure you are overlaying. So it created the array
after c12 since it is also a subfield of PF1_t. Others have already
shown you the correct way to do this, which is to create a group field
that the c1 - c12 fields will overlay using next. Then overlay the
array over the same group field.
The point here is that *NEXT does not overlay starting after the
previous overlay *NEXT. It starts after the previous subfield.
No, it starts at the next available position in the data structure.
D ds ds
D suba 1 5a
D subb 3a
D subc 2 3a
D subd 2a overlay(ds:*next)
/free
ds = '123456789';
subd = *all'd';
dsply ds;
return;
DSPLY 12345678dd
Subfield sub4 starts at position 9, after subb, not at position 4, after
subc.
OVERLAY(dsname:*next) means "next available position in the data
structure", which, as Jon has been saying, is the same as not specifying
OVERLAY at all.
Arguably, *NEXT shouldn't even have been allowed for overlay on a data
structure.
As an Amazon Associate we earn from qualifying purchases.