× The internal search function is temporarily non-functional. The current search engine is no longer viable and we are researching alternatives.
As a stop gap measure, we are using Google's custom search engine service.
If you know of an easy to use, open source, search engine ... please contact support@midrange.com.




On 15/09/2009, at 11:35 PM, David FOXWELL wrote:


In the example of Pgm A, if PgmId= Pgm C, how would you code that program's prototype?

Given that Pgm A doesn't know anything about Pgm C except that if it calls RouterPgm giving the name of Pgm C then Pgm C will be invoked with whatever parameters were passed to the router then there is no reason to code a prototype for Pgm C in Pgm A.


Maybe *OMIT is not a good idea.


*OMIT is fine as long as you understand what you're doing with it. Specifying *OMIT will cause a null pointer to be passed. This can be passed on in turn as long as your code can handle it.

Based on the information you provided I would change the sequence of the parameters and code the prototype for the router program as:

D ROUTER PR
D errMsg 1024 (as CONST OPTIONS(*VARSIZE) if input-only)
D PgmID 21 CONST OPTIONS(*VARSIZE)
D p1 ???? OPTIONS(*NOPASS : *OMIT)
D p2 ???? OPTIONS(*NOPASS : *OMIT)
D p3 ???? OPTIONS(*NOPASS : *OMIT)

I would put errMsg near the front because it looks like it is always present. I would put the parameters last so I can easily add support for more. I presume the parameters can be bi-directional therefore no CONST. I would use both *NOPASS and *OMIT so I don't have to code *OMIT for parameters after the last one I care about. This would be both more flexible and cleaner to code. I may also choose to specify other keywords depending on how the parameters are actually used.

The router program would have the prototypes for the various programs it knows how to call or perhaps a generic prototype using a variable name for the EXTPGM keyword or perhaps I would build an argument array and use the CALLPGMV built-in MI instruction to pass the varying argument list to the program named in PgmID.

Regards,
Simon Coulter.
--------------------------------------------------------------------
FlyByNight Software OS/400, i5/OS Technical Specialists

http://www.flybynight.com.au/
Phone: +61 2 6657 8251 Mobile: +61 0411 091 400 /"\
Fax: +61 2 6657 8251 \ /
X
ASCII Ribbon campaign against HTML E-Mail / \
--------------------------------------------------------------------




As an Amazon Associate we earn from qualifying purchases.

This thread ...

Replies:

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

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.