Thanks, Simon.
No I think I understood it.
The slogan is Keep It Simple, Stupid.... 
:-(((

> -----Original Message-----
> From: Simon Coulter [mailto:shc@xxxxxxxxxxxxxxxxx]
> Sent: 17. juuli 2003. A. 22:25
> To: C programming iSeries / AS400
> Subject: Re: [C400-L] Calling RPG program from ILE-C
> 
> 
> 
> Hello Jevgeni,
> 
> Since C uses the library list by default you should be able 
> to make this work 
> by:
> 
> #pragma linkage( PROGA, OS )
> void PROGA( ..... );
> 
> int main( void )
> {
>       PROGA( .... );
> }
> 
> Of course, that method presumes you know the program name at 
> compile-time. If 
> you don't know the program name until run-time then you can 
> use the RSLVSP MI 
> function to resolve a system pointer to the progam object and 
> then call it using 
> a C function pointer.
> 
> You would first resolve to the program in the KLIB123 
> library. If not found then 
> resolve to the program in the KAPBASELIB. Once you have a 
> resolved pointer you 
> can invoke it using the pointer. For example:
> 
> #include <rslvsp.mih>
> 
> #pragma linkage( KBPGM_T, OS)
> typedef void KBPGM_T( void * parm1, void * parm2 );
> KBPGM_T * KBPGM;
> 
> int main( void )
> {
>       void * parm1, * parm2;
>       char * program;        
>       char * library;
> 
>       program = "PROGA";
>       library = "KLIB123";
> 
>       /* 
>       ** May need an exception handler for MCH3601 
>       ** See #pragma exception_handler in C Language Reference
>       */
> 
>       KBPGM = rslvsp( WLI_PGM, program, library, _AUTH_NONE );
> 
>       if (!KBPGM ) 
>       {
>               library = "KAPBASELIB";
>               KBPGM = rslvsp( WLI_PGM, program, library, _AUTH_NONE );
>       }
> 
>       KBPGM( parm1, parm2 );
> }
> 
> If you know that a program with the right name will exist in 
> the library list 
> then you could simply set library to *LIBL before resolving 
> and skip the second 
> resolve step.
> 
> Regards,
> Simon Coulter.
> --------------------------------------------------------------------
>    FlyByNight Software         AS/400 Technical Specialists       
>                                                                   
>    http://www.flybynight.com.au/                                  
>    Phone: +61 3 9419 0175   Mobile: +61 0411 091 400        /"\   
>    Fax:   +61 3 9419 0175   mailto: shc@xxxxxxxxxxxxxxxxx   \ /   
>                                                              X    
>                  ASCII Ribbon campaign against HTML E-Mail  / \   
> --------------------------------------------------------------------
> 
> _______________________________________________
> This is the C programming iSeries / AS400 (C400-L) mailing list
> To post a message email: C400-L@xxxxxxxxxxxx
> To subscribe, unsubscribe, or change list options,
> visit: http://lists.midrange.com/mailman/listinfo/c400-l
> or email: C400-L-request@xxxxxxxxxxxx
> Before posting, please take a moment to review the archives
> at http://archive.midrange.com/c400-l.
> 
> 


This thread ...


Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2019 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 here. If you have questions about this, please contact [javascript protected email address].