David;
Don't know if this will help but these are the general rules I follow:
If possible group related parms together as in messageId, messageData, messageLength
1. All required parms come first, in your case I would have Pgmid, and ErrorMessage as the first two parameters.
2. Next, omit able parms, which I almost always define with Options(*OMIT : *NOPASS).
3. Next, *NOPASS parameters
So lets say your router program has these possible parms:
pgmId
errorMessage
messgeId
messageData
messageLength
customerNumber
orderNumber
itemNumber
itemQuantity
billName
billAddress1
billAddress2
billCityStZip
The prototype would look like this:
router PR ExtPgm('ROUTER')
pgmid 10I 0 Const
errormessage 50A Const Varying
messageid 7A Const Options(*OMIT *NOPASS)
messageData * Const Options(*OMIT *NOPASS)
messagelength 10I 0 Const Options(*OMIT *NOPASS)
customerNumber 9P 0 Const Options(*OMIT *NOPASS)
orderNumber 12P 0 Const Options(*OMIT *NOPASS)
itemNumber 15P 0 Const Options(*OMIT *NOPASS)
itemQuantity 5P 0 Const Options(*OMIT *NOPASS)
billName 60A Const Varying Options(*NOPASS)
billAddress1 60A Const Varying Options(*NOPASS)
billAddress2 60A Const Varying Options(*NOPASS)
billCityStZip 60A Const Varying Options(*NOPASS)
Personally though I would pass a pointer to a data structure, which may/could be different for each pgmId that the router program would handle with a length and formatId, similar to many IBM APIs, also known as the poor man's procedure overloading.
router PR ExtPgm('ROUTER')
pgmid 10I 0 Const
errormessage 50A Const Varying
dsBase * Const
dsSize 10I 0 Const
dsFormat 10A Const
The down side of this approach is that the compiler can't do parameter checking for each field in the data structure(s), but because you have to do much of the parameter checking when using *OMIT anyway it may be simpler to pass formats (data structure(s)).
Duane Christen
--
Duane Christen
Senior Software Engineer
(319) 790-7162
Duane.Christen@xxxxxxxxxx
Visit PAETEC.COM
-----Original Message-----
From: rpg400-l-bounces@xxxxxxxxxxxx [mailto:rpg400-l-bounces@xxxxxxxxxxxx] On Behalf Of David FOXWELL
Sent: Tuesday, September 15, 2009 8:36 AM
To: RPG programming on the IBM i / System i
Subject: OPTIONS(*OMIT)?
Hi can someone help me out with this?
A program calls a router program with the name of the program to be called by the router plus other optional parameters.
I wanted to configure the router program to accept several other parameters conditioned by OPTIONS(*OMIT).
Example
In Pgm A
CallP RouterPgm ( PgmID : *OMIT : *OMIT : MyParm1 : ErrorMessage );
In Pgm B
CallP RouterPgm ( PgmID : MyParm1 : MyParm2 : MyParm3 : ErrorMessage );
*OMIT is being used when the parameters have no relevance in the calling program.
In the example of Pgm A, if PgmId= Pgm C, how would you code that program's prototype?
Maybe *OMIT is not a good idea.
--
This is the RPG programming on the IBM i / System i (RPG400-L) mailing list To post a message email: RPG400-L@xxxxxxxxxxxx To subscribe, unsubscribe, or change list options,
visit:
http://lists.midrange.com/mailman/listinfo/rpg400-l
or email: RPG400-L-request@xxxxxxxxxxxx
Before posting, please take a moment to review the archives at
http://archive.midrange.com/rpg400-l.
As an Amazon Associate we earn from qualifying purchases.