MIDRANGE dot COM Mailing List Archive



Home » RPG400-L » June 2008

Re: CL Optional Parameter Question



fixed

You can call a CL with defined parameters, without passing parameters. You
just need to handle the MCH error that comes about from using the
non-initialized variable.

--
Mike Wills
Midrange Programmer/Analyst

Sick of corporate radio and hungry for something new?
http://thenextgenerationofradio.com
http://twitter.com/MikeWills | http://friendfeed.com/mikewills

On Mon, Jun 16, 2008 at 4:53 PM, Scott Klement <rpg400-l@xxxxxxxxxxxxxxxx>
wrote:

Hi Bruce,

I'm no expert, I'm trying to figure this stuff out. I'm looking at the
following page of the Information Center:
http://publib.boulder.ibm.com/infocenter/iseries/v5r4/topic/rbam6/passp.htm

Here's a quote from that page:

- -

When calling an original program model (OPM) CL program, the number of
parameters that are passed to it must exactly match the number that is
expected by the program. The number that is expected is determined at
the time the program is created. (The operating system prevents you from
calling a program with more or fewer parameters than the program
expects). When calling an ILE program or procedure, the operating system
does not check the number of parameters that are passed on the call. In
addition, the space where the operating system stores the parameters is
not reinitialized between procedure calls. Calling a procedure that
expects "n" parameters with "n-1" parameters makes the system use
whatever is in the parameter space to access the "nth" parameter. The
results of this action are very unpredictable. This also applies to
procedures written in other ILE languages that call CL procedures or are
called by CL procedures.

- -

That paragraph states "When calling an ILE program or procedure", then
proceeds to say the space is not reinitialized between calls. Now that
I'm reading this again after you've told me I'm wrong, I do see that it
uses the verbiage "procedure calls"... but the fact that (before that)
it says "program or procedure" makes this paragraph very easy to
interpret the way I originally interpreted it (that it applies to both
program and procedure calls).

As usual, IBM documentation is anything but clear.


Bruce Vining wrote:
Hi, Scott

Should have stopped on your first note lol. The code path for a *PGM
call will get you the exception. There was a bug along these lines a
loooong time ago, but it has been corrected (perhaps as long as two years
ago?).

Bruce

Scott Klement <rpg400-l@xxxxxxxxxxxxxxxx> wrote:
...and in ILE CL, the parameter storage isn't reinitialized between
calls, is it? So you couldn't rely on the MCH3601 being generated each
time, unless *OMIT is passed from the CALL command, right?

I'm with Francis. Use a command front-end. Or, if it's REALLY
important that you use the CALL command, put an RPG front-end over your
CL program.


Scott Klement wrote:
Hi Bruce,

Wouldn't you still get a "Parameters passed on CALL do not match those
required." error when you tried to call this? Unless you used ILE CL,
that is?


Bruce Vining wrote:
Sure. But it does need to be a *PGM.

PGM PARM(&PARM1)
DCL VAR(&PARM1) TYPE(*CHAR) LEN(1)
DCL VAR(&TEST) TYPE(*CHAR) LEN(1)
CHGVAR VAR(&TEST) VALUE(&PARM1)
MONMSG MSGID(MCH3601) EXEC(DO)
RCVMSG MSGTYPE(*LAST)
SNDPGMMSG MSG('Not sent') TOPGMQ(*EXT)
RETURN
ENDDO
IF COND(&PARM1 = Y) +
THEN(SNDPGMMSG MSG('Sent') TOPGMQ(*EXT))
ELSE CMD(SNDPGMMSG MSG('Sent but no Y') +
TOPGMQ(*EXT))
ENDPGM

Bruce Vining



--
This is the RPG programming on the AS400 / iSeries (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.







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