Mark,
I'm a little puzzled by something you said in the linked thread:
"...Another way to avoid this is to "library qualify" the call, as follows:
Declare a variable named QualPgm as character 20, with two fields, pgmNam
and pgmLib, defined as char 10, starting at position 1 and 11 respectively
in the QualPgm "data structure". Fill in the pgmNam at runtime, as we did
previously, but also "plug
in<
http://archive.midrange.com/rpg400-l/200902/msg00256.html#>"
the correct library name in the pgmLib field (as it appears your program may
already know this library name, since your program is dynamically changing
the library list.)
Then, use the qualified name on the CALL, as follows:
c call qualPgm"
Maybe I'm misunderstanding what you're trying to say/do, but when you do the
call to callPgm, it will look at the variable name and will check if it's
been changed since the last call. This is true *whether or not* the name is
library qualified.
For instance, if I have the following:
D PgmToCallName S 21A
D PgmToCall PR Extpgm(PgmToCallName)
D Parm1 10A
PgmToCallName = 'MYLIB/MYPGM';
callp(e) PgmToCall;
callp(e) PgmToCall;
and between the two calls, I recompile MYPGM in MYLIB, the old copy will be
moved into QRPLOBJ. The second call will actually call that old version of
MYPGM in QRPLOBJ rather than the new version in MYLIB, *even though the
value of PgmToCallName is 'MYLIB/MYPGM'*. It doesn't matter even if I
explicitly set PgmToCallName between the calls, e.g.:
PgmToCallName = 'MYLIB/MYPGM';
callp(e) PgmToCall;
PgmToCallName = 'MYLIB/MYPGM';
callp(e) PgmToCall;
So if the PgmToCallName variable is the same as on the previous call, OS/400
will use the previously saved pointer.
It's also worth pointing out that you can't force a re-resolve by supplying
a dummy value (either a non-existent program or an invalid program name),
e.g.:
PgmToCallName = 'MYLIB/MYPGM';
callp(e) PgmToCall;
PgmToCallName = 'DUMMY';
callp(e) PgmToCall;
PgmToCallName = 'MYLIB/MYPGM';
callp(e) PgmToCall;
(assuming there is no program called DUMMY, of course). OS/400 won't change
its internal saved pointer *until* it actually resolves the pointer to the
specified program. So in the above case, the initial call to MYLIB/MYPGM
calls MYPGM in MYLIB and OS/400 saves the resolved pointer and the
'MYLIB/MYPGM' variable. Then MYPGM is recompiled, so the pointer now points
to the version in QPRLOBJ. Then OS/400 tries to call DUMMY and fails
(because DUMMY doesn't exist) but it *doesn't* update its internal variable
& pointer. Then on the second call to 'MYLIB/MYPGM', it sees that the
variable hasn't changed, so it uses the pointer from the first call, thus
calling the MYPGM object in QRPLOBJ.
You probably know this, but I thought it was worth pointing out, since this
exact scenario sems to be what James was having (with his program FOO being
replaced between calls).
Rory
On Wed, Aug 12, 2009 at 11:53 AM, Mark S. Waterbury <
mark.s.waterbury@xxxxxxx> wrote:
Hi, James:
The answer is here:
http://archive.midrange.com/rpg400-l/200902/msg00256.html
Cheers,
Mark S. Waterbury
As an Amazon Associate we earn from qualifying purchases.