Mike Cunningham | 28 Sep 14:51 2009

Variable number of parameters in CL

Is there any way to keep a CL program from failing if too few parameters are passed like you can in RPG by
detecting the number of parameters with %parms() and then not referencing the missing parameter(s) if
they were not passed?  I have a CL program that is called from about 50 other applications and I need to add a
new parameter for just one new function to be used currently in one application.
--

-- 
This is the Midrange Systems Technical Discussion (MIDRANGE-L) mailing list
To post a message email: MIDRANGE-L@...
To subscribe, unsubscribe, or change list options,
visit: http://lists.midrange.com/mailman/listinfo/midrange-l
or email: MIDRANGE-L-request@...
Before posting, please take a moment to review the archives
at http://archive.midrange.com/midrange-l.

Simon Coulter | 28 Sep 15:20 2009
Picon

Re: Variable number of parameters in CL


On 28/09/2009, at 10:51 PM, Mike Cunningham wrote:

> Is there any way to keep a CL program from failing if too few  
> parameters are passed like you can in RPG by detecting the number of  
> parameters with %parms() and then not referencing the missing  
> parameter(s) if they were not passed?  I have a CL program that is  
> called from about 50 other applications and I need to add a new  
> parameter for just one new function to be used currently in one  
> application.

Make it a CLLE program.

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

--

-- 
This is the Midrange Systems Technical Discussion (MIDRANGE-L) mailing list
To post a message email: MIDRANGE-L@...
To subscribe, unsubscribe, or change list options,
visit: http://lists.midrange.com/mailman/listinfo/midrange-l
(Continue reading)

Vern Hamberg | 28 Sep 15:35 2009
Picon
Picon

Re: Variable number of parameters in CL

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.

HTH
Vern

Simon Coulter wrote:
> On 28/09/2009, at 10:51 PM, Mike Cunningham wrote:
>
>   
>> Is there any way to keep a CL program from failing if too few  
>> parameters are passed like you can in RPG by detecting the number of  
>> parameters with %parms() and then not referencing the missing  
>> parameter(s) if they were not passed?  I have a CL program that is  
>> called from about 50 other applications and I need to add a new  
>> parameter for just one new function to be used currently in one  
>> application.
>>     
>
> Make it a CLLE program.
>
> Regards,
> Simon Coulter.
> --------------------------------------------------------------------
>     FlyByNight Software         OS/400, i5/OS Technical Specialists
>
(Continue reading)

Simon Coulter | 28 Sep 16:02 2009
Picon

Re: Variable number of parameters in CL


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.

(Continue reading)

Vern Hamberg | 28 Sep 16:57 2009
Picon
Picon

Re: Variable number of parameters in CL

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
(Continue reading)

Mike Cunningham | 28 Sep 15:44 2009

RE: Variable number of parameters in CL

It is already. But that response led me to this http://www.itjungle.com/fhg/fhg081104-story02.html so
it answered my question. Thanks 

-----Original Message-----
From: midrange-l-bounces@...
[mailto:midrange-l-bounces@...] On Behalf Of Simon Coulter
Sent: Monday, September 28, 2009 9:21 AM
To: Midrange Systems Technical Discussion
Subject: Re: Variable number of parameters in CL

On 28/09/2009, at 10:51 PM, Mike Cunningham wrote:

> Is there any way to keep a CL program from failing if too few  
> parameters are passed like you can in RPG by detecting the number of  
> parameters with %parms() and then not referencing the missing  
> parameter(s) if they were not passed?  I have a CL program that is  
> called from about 50 other applications and I need to add a new  
> parameter for just one new function to be used currently in one  
> application.

Make it a CLLE program.

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                                   \ /
(Continue reading)

Birgitta Hauser | 28 Sep 15:31 2009
Picon

AW: Variable number of parameters in CL

Hi,

What if you check for MCH3601 for the optional parameters?

Mit freundlichen Grüßen / Best regards

Birgitta Hauser

"Shoot for the moon, even if you miss, you'll land among the stars." (Les
Brown)
"If you think education is expensive, try ignorance." (Derek Bok)
"What is worse than training your staff and losing them? Not training them
and keeping them!"

-----Ursprüngliche Nachricht-----
Von: midrange-l-bounces@...
[mailto:midrange-l-bounces@...] Im Auftrag von Simon Coulter
Gesendet: Monday, 28. September 2009 15:21
An: Midrange Systems Technical Discussion
Betreff: Re: Variable number of parameters in CL

On 28/09/2009, at 10:51 PM, Mike Cunningham wrote:

> Is there any way to keep a CL program from failing if too few  
> parameters are passed like you can in RPG by detecting the number of  
> parameters with %parms() and then not referencing the missing  
> parameter(s) if they were not passed?  I have a CL program that is  
> called from about 50 other applications and I need to add a new  
> parameter for just one new function to be used currently in one  
> application.
(Continue reading)

Birgitta Hauser | 29 Sep 06:46 2009
Picon

WDSc / RDi Debugger and global variables?

Hi,

May be this is not quite the correct forum, but I hope here are also some
guys who use the WDSc/RDi Debugger for RPG and can point me to the right
direction.

I need to debug CGI programs and called procedures. To debug I use the
WDSC/RDi-Debugger (Version 7.1). 

Unfortunately my coworker uses exported procedures, but defines almost
everything globally. 
... and if the exported procedures are not called in a predefined sequence,
the CGI-program may fail or at least deliver wrong results. 
To find out what's wrong, I need to debug the programs and see the content
of these global variables.

Until now I didn't find how to make the content of the global variables
visible (I only can see the content of the local variables).

Can someone point me into the right direction, i.e. describe me how to see
the content of the global variables within the WDSC/RDi Debugger.
Or do I really have to go back to STRSRVJOB and STRDBG (which is quite
annoying if you have to debug CGI programs)?

Thanks in advance.

Mit freundlichen Grüßen / Best regards

Birgitta Hauser

(Continue reading)


Gmane