|
Hi Charles, > MyExtPgm(); > System('ADDLIBLE MYOTHLIB POSITION(*FIRST)'); > MyExtPgm(); Programs on the iSeries are called using something called a 'system pointer.' What happens is the first time you call the program, it finds the program by searching your library list, and gets a pointer to it. In calls from that point forward, it uses that pointer -- so it doesn't matter that you changed the library list in-between. > At this point, it seems that my ILE RPG program resolved the EXTPGM at the > first run; thus finding the standard copy. When it was called again after > changing the library list the name wasn't re-resolved. Exactly. See, I didn't need to explain it, you already knew :) The next obvious question is... how to solve the problem? Well, one easy way is to use a variable for the program name. Change the library before you call the prototype and it'll re-resolve the program. For example: H DFTACTGRP(*NO) BNDDIR('QC2LE') D PgmName s 21A inz('*LIBL/SOMEPGM') D MyExtPgm pr extpgm(PgmName) D system PR 10I 0 extproc('system') D command * value options(*string) D wait s 1A /free system('RMVLIBLE LIB2'); dsply 'Calling program from lib1' '' wait; MyExtPgm(); system('ADDLIBLE LIB2 *FIRST'); dsply 'Calling program from lib2' '' wait; pgmName='LIB2/SOMEPGM'; // library name must change. MyExtPgm(); *inlr = *on; /end-free Another possible solution is to call the program via the system() API, just as you did with the ADDLIBLE command: H DFTACTGRP(*NO) BNDDIR('QC2LE') D system PR 10I 0 extproc('system') D command * value options(*string) D wait s 1A /free system('RMVLIBLE LIB2'); dsply 'Calling program from lib1' '' wait; system('CALL SOMEPGM'); system('ADDLIBLE LIB2 *FIRST'); dsply 'Calling program from lib2' '' wait; system('CALL SOMEPGM'); *inlr = *on; /end-free There's probably another way that uses an MI function to do this, but I can't think of it off the top of my head... But, hey, how many solutions do you need? :)
As an Amazon Associate we earn from qualifying purchases.
This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].
Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.