Rory, you're performing an OUT prior to the call, which is unlocking the
data area. Check this out:
"You can specify the optional reserved word *LOCK. When *LOCK is
specified, the data area remains locked after it is updated. When *LOCK
is not specified, the data area is unlocked after it is updated."
However I'm not so sure the called program can access that locked data
area.
-----Original Message-----
From: rpg400-l-bounces@xxxxxxxxxxxx
[mailto:rpg400-l-bounces@xxxxxxxxxxxx] On Behalf Of Rory Hewitt
Sent: Tuesday, January 13, 2009 2:33 PM
To: RPG programming on the IBM i / System i
Subject: Re: Passing unwanted parameters
Scott,
In fact, the RPG manual isn't quite correct...
From the "Data Area Operations" section at
http://publib.boulder.ibm.com/infocenter/iseries/v5r3/index.jsp?topic=/b
ooks_web/c092508502.htm(
*my italics*):
"A data structure defined with a U in position
23<
http://publib.boulder.ibm.com/infocenter/iseries/v5r3/topic/books_web
/c0925085332.htm#HDRD23>of
the definition specifications indicates that the data structure is a
data
area. You may specify the DTAARA keyword for a data area data structure,
if
specified you can use the IN, OUT and UNLOCK operation codes to specify
further operations for the data area. *The data area is automatically
read
and locked at program initialization time, and the contents of the data
structure are written to the data area when the program ends with LR
on*. If
the data area for a data area data structure is not found, it will be
created with an initial value of blanks. If the library list was
searched
for the data area, the new data area will be created in QTEMP."
If you have the following definition in both caller and called:
D ExtraParm UDS 32 Dtaara(EXTRAPARM)
then the data area is created in QTEMP (if it doesn't exist) read and
locked
with *EXCLRD in the caller. In the called program, it's read, but it's
already locked. However, when the called program ends, the lock is
released!
So when control returns to the caller, the lock is gone...
To me this seems like a bug - surely the program which initially read it
and
obtained the lock (the caller) should keep the lock until *it's* ended?
Rory
p.s. My code:
CALLER:
D ExtraParm UDS 32 Dtaara(EXTRAPARM)
/free
ExtraParm = *all'abc';
out(e) ExtraParm;
callp test2();
dsply ExtraParm;
return;
/end-free
CALLED:
D ExtraParm UDS 32 Dtaara(EXTRAPARM)
/free
dsply ExtraParm;
ExtraParm = *all'def';
out(e) ExtraParm;
return;
/end-free
As an Amazon Associate we earn from qualifying purchases.