MIDRANGE dot COM Mailing List Archive



Home » MIDRANGE-L » September 2009

Re: Variable number of parameters in CL



fixed

Yep - no global MONMSG.

My wording was a little unclear, I fear. It was early and had just awakened. What I meant was a "MONMSG after first use of each optional parameter".

Also as part of clean programming, in that MONMSG, do a RCVMSG RMV(*YES) - avoids cluttering the job log and/or causing undue alarm on the part of users.

I've not used internal variables myself, because the main reason for doing this involves RTV* commands, where I don't even WANT to do certain things when a parameter is not passed - all are essentially optional. Besides, the parameters are the ones you have to return values back in. Then I really just want to skip processing when I get an MCH3601. Although I can see value in setting flow control *LGL variables in this case, either by some kind of operation that triggers the MONMSG, or by calling that CEETSTA API, which I will have to look into.

Vern

Simon Coulter wrote:
On 28/09/2009, at 11:35 PM, Vern Hamberg wrote:

There is still no such thing as a count of parameters that I remember,
so put a MONMSG MCH3401 (MCH3601? I forget which) after the first use of
the optional parameters, then use a GOTO to skip around the new code.
There might also be some newer commands for handling errors since V5R3
and up - not sure. Thought I'd seen something about DO WHILE that
involved message IDs once at COMMON. But don't quote me on that.

It's MCH3601.

I presumed he meant how to avoid the error on call (CPF0001 preceded by CPD0172. Making it a CLLE will avoid that. I didn't consider how he would handle KNOWING which ones were passed or not (but I note that was in his initial question).

Dealing with optional parameters in CL requires you to define internal variables for each of the optional parameters. Copy the optional parameter to the internal version. Monitor for MCH3601 and assign a sensible default (remembering to remove the exception message from the joblog). Once past all the parameter checks the body of the code only ever references the internal variables.

Returning information to the caller is similar. Copy the internal variable to the optional variable and deal with any MCH3601.

Don't do a global MONMSG for MCH3601.

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 / \
--------------------------------------------------------------------








Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2014 by MIDRANGE dot 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