We were told that MCH3601 was not as reliable as using CEETSTA API
/* GET PARM COUNT - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
CHGVAR VAR(&PARMCOUNT) VALUE(0)
PARMCHECK: DOFOR VAR(&PARMIDX) FROM(1) TO(5)
CHGVAR VAR(&PARMNUMBER) VALUE(&PARMIDX)
CALLPRC PRC(CEETSTA) PARM(&PARMRESULT &PARMNUMBER *OMIT)
IF COND(&PARMRESULT *NE 1) THEN(DO)
LEAVE CMDLBL(PARMCHECK)
ENDDO
CHGVAR VAR(&PARMCOUNT) VALUE(&PARMCOUNT + 1)
ENDDO
/*----------------------------------------------------------------------------*/
/* First 4 parms are required */
/*----------------------------------------------------------------------------*/
IF COND(&PARMCOUNT *LT 2) THEN(DO)
RETURN
ENDDO
You do have to hard code the parm count unfortunately.
I think MCH3601 works well if you document that you never intend to have *NULL as a valid value passed to a param.
-Matt
-----Original Message-----
From: MIDRANGE-L [mailto:midrange-l-bounces@xxxxxxxxxxxx] On Behalf Of DrFranken
Sent: Wednesday, January 31, 2018 9:58 AM
To: Midrange Systems Technical Discussion <midrange-l@xxxxxxxxxxxx>
Subject: Re: Checking for missing parameters in CL
Strange duck that CL, just do stuff and if there is smoke, catch it, extinguish it, and move on!
I have used your method as well but I like David's method better since we got pointers and such. I just HATE inviting Mr MCH to the party!
- Larry "DrFranken" Bolhuis
www.Frankeni.com
www.iDevCloud.com - Personal Development IBM i timeshare service.
www.iInTheCloud.com - Commercial IBM i Cloud Hosting.
On 1/31/2018 11:48 AM, dlclark@xxxxxxxxxxxxxxxx wrote:
"MIDRANGE-L" <midrange-l-bounces@xxxxxxxxxxxx> wrote on 01/31/2018
11:38:56 AM:
So I tried something similar in CL...
pgm (&parm1)
dcl &parm1 *char (10)
dcl &p1addr *ptr
chgvar &p1addr (%address(&parm1))
if (&p1addr = *null) then(do)
/* do something if parameter wasn't specified */ enddo else do
/* do something else if the parameter was specified */ endpgm
So far it seems to work as I expect.
We have always done it as follows. But, the above makes
sense, too. Thanks for the info.
PGM PARM(&OPTRUN)
DCLPRCOPT TEXT('IM LIFO Inventory Extensions') +
DFTACTGRP(*NO) ACTGRP(WINWISE) +
BNDSRVPGM((SRVWS01) (UTSECURSV))
/* optional parameters */
DCL VAR(&OPTRUN) TYPE(*CHAR) LEN(10)
/* parameter variables */
DCL VAR(&RUNOPT) TYPE(*CHAR) LEN(10) VALUE('*PRELIM')
/* receive optional parameters */
CHGVAR VAR(&RUNOPT) VALUE(&OPTRUN) /* run option? */
MONMSG MSGID(MCH3601) EXEC(DO) /* parm not passed */
RCVMSG MSGTYPE(*LAST) RMV(*YES) /* remove escape +
message from job log */ ENDDO
Sincerely,
Dave Clark
--
This is the Midrange Systems Technical Discussion (MIDRANGE-L) mailing list To post a message email: MIDRANGE-L@xxxxxxxxxxxx To subscribe, unsubscribe, or change list options,
visit:
https://urldefense.proofpoint.com/v2/url?u=https-3A__lists.midrange.com_mailman_listinfo_midrange-2Dl&d=DwICAg&c=2S-2xx8Cum_thMfWs-kOOHQTwolPvSZ4PFLhr1wDDGs&r=wgq2KO1Tl8HswJht2RKpmz7qvL2YDU_M-VhnRH6r43I&m=w2cfNsAByJ-LfTrc4e2AZqHTlEsLE47Gx5hTBQEtkUg&s=SKV-ya2EMEAL1w476CWjeJU4U_F-e975u3fjDgxIweE&e=
or email: MIDRANGE-L-request@xxxxxxxxxxxx Before posting, please take a moment to review the archives at
https://urldefense.proofpoint.com/v2/url?u=https-3A__archive.midrange.com_midrange-2Dl&d=DwICAg&c=2S-2xx8Cum_thMfWs-kOOHQTwolPvSZ4PFLhr1wDDGs&r=wgq2KO1Tl8HswJht2RKpmz7qvL2YDU_M-VhnRH6r43I&m=w2cfNsAByJ-LfTrc4e2AZqHTlEsLE47Gx5hTBQEtkUg&s=DBNBeH0qG6w5L1T_76e4TsjYK2-DVxeJvsQecF39MDw&e=.
Please contact support@xxxxxxxxxxxx for any subscription related questions.
Help support midrange.com by shopping at amazon.com with our affiliate link:
https://urldefense.proofpoint.com/v2/url?u=http-3A__amzn.to_2dEadiD&d=DwICAg&c=2S-2xx8Cum_thMfWs-kOOHQTwolPvSZ4PFLhr1wDDGs&r=wgq2KO1Tl8HswJht2RKpmz7qvL2YDU_M-VhnRH6r43I&m=w2cfNsAByJ-LfTrc4e2AZqHTlEsLE47Gx5hTBQEtkUg&s=EzAaw1AWys74t0MFcEqega6aXnZViWtHdn6Md392GbE&e=
As an Amazon Associate we earn from qualifying purchases.