|
All,
I really like the idea coding optional parameters as (*NOPASS : *OMIT).
Particularly when the parameter is question ends up in a null capable
file field.
However, as far as I can tell actual implementation is ugly beyond
belief.
/free
if bin_Required();
wToBin = AskUserForBin();
Inventory_MoveSerialized(wPlant:wSerial:wToStkRm:wToBin);
else;
Inventory_MoveSerialized(wPlant:wSerial:wToStkRm);
endif;
*INLR = *ON;
return;
/end-free
p Inventory_MoveSerialized...
p b export
d Inventory_MoveSerialized...
d pi n
d plant like(t_PlantID) const
d serial like(t_SerialNumber) const
d toStkRm like(t_StockRoom) const
d toBin like(t_BinLocation) const
d options(*NOPASS:*OMIT)
d parm5 10a const options(*NOPASS:*OMIT)
/free
if %parms >= 5;
if parm5 <> *OMIT;
SomeOtherProc1(plant:parm5);
else;
SomeOtherProc1(plant:*OMIT);
endif;
else
SomeOtherProc1(plant);
endif;
if %parms >= 4;
if parm4 <> *OMIT;
SomeOtherProc2(plant:serial:toStkRm:toBin);
else
SomeOtherProc2(plant:serial:toStkRm:*OMIT);
endif;
else
SomeOtherProc2(plant:serial:toStkRm);
endif;
if %parms >= 5;
if parm5 <> *OMIT;
if toBin <> *OMIT;
SomeOtherProc3(plant:toBin:parm5);
else;
SomeOtherProc3(plant:*OMIT:parm5);
endif;
elseif toBin <> *OMIT;
SomeOtherProc3(plant:toBin:*OMIT);
else
SomeOtherProc3(plant:*OMIT:*OMIT);
endif;
elseif %parms >= 4;
if toBin <> *OMIT;
SomeOtherProc3(plant:toBin);
else;
SomeOtherProc3(plant:*OMIT);
endif;
else
SomeOtherProc3(plant);
endif;
return;
/end-free
Calling SomeOtherProc1 & SomeOtherProc2 is ugly enough, but calling
SomeOtherProc3 which uses two *NOPASS:OMIT parms is horrible. I'd hate
to imagine what it would look like if there were more *NOPASS:*OMIT
parameters being passed to it.
So how are you all dealing with this wreak?
Somebody correct me if I'm wrong, but I'm thinking that it might be best
to drop the *NOPASS, since I believe that I can pass along (by const
reference) an *OMITted parameter to another procedure with no problems.
So for instance this would work with parm5 *OMITted or not:
/free
if parm5 <> *OMIT;
dsply parm5;
endif;
SomeOtherProc1(plant:parm5);
/end-free
It would really be nice if RPG allowed you to make a varible NULL
(*OMITted)
So for instance you could have:
d wToBin s like(t_BinLocation) inz(*OMIT)
/free
if bin_Required();
wToBin = AskUserForBin();
endif;
Inventory_MoveSerialized(wPlant:wSerial:wToStkRm:wToBin);
*INLR = *ON;
return;
/end-free
Then in the Inventory_MoveSerialized even with *NOPASS I could have
/free
if %parms >= 5;
wParm5 = parm5;
else
wParm5 = *OMIT;
endif;
if %parms >= 4;
wToBin = toBin;
else
wToBin = *OMIT;
endif;
SomeOtherProc1(plant:parm5);
SomeOtherProc2(plant:serial:toStkRm:toBin);
SomeOtherProc3(plant:toBin:parm5);
return;
/end-free
Thoughts?????
Thanks in advance,
Charles Wilt
--
iSeries Systems Administrator / Developer
Mitsubishi Electric Automotive America
ph: 513-573-4343
fax: 513-398-1121
As an Amazon Associate we earn from qualifying purchases.
This mailing list archive is Copyright 1997-2025 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.