Dear Roger.

Example on optional parms:

PGM PARM(&OPTION &REPORT &ORORID &pPMVM &pACB &pDIPD) /* last 3
parms are optional */

DCL VAR(&option) TYPE(*CHAR) LEN(02)
DCL VAR(&report) TYPE(*CHAR) LEN(35)
DCL VAR(&ORORID) TYPE(*DEC) LEN(9 0)
DCL VAR(&pPMVM) TYPE(*CHAR) LEN(1)
DCL VAR(&pACB) TYPE(*CHAR) LEN(1)
DCL VAR(&pDIPD) TYPE(*CHAR) LEN(1)

DCL VAR(&PMVM) TYPE(*CHAR) LEN(1)
DCL VAR(&ACB) TYPE(*CHAR) LEN(1)
DCL VAR(&DIPD) TYPE(*CHAR) LEN(1)

/* vars for processing optional parms */
DCL &p4 *CHAR 4
DCL &p5 *CHAR 4
DCL &p6 *CHAR 4
DCL &PARMNO *CHAR 4

/* init optional parms */
CHGVAR VAR(&PMVM) VALUE(' ')
CHGVAR VAR(&ACB) VALUE(' ')
CHGVAR VAR(&DIPD) VALUE(' ')


/* are optional parms passed ? */
CHGVAR VAR(%BIN(&PARMNO)) VALUE(4)
CALLPRC PRC(CEETSTA) PARM(&p4 &PARMNO *OMIT)
CHGVAR VAR(%BIN(&PARMNO)) VALUE(5)
CALLPRC PRC(CEETSTA) PARM(&p5 &PARMNO *OMIT)
CHGVAR VAR(%BIN(&PARMNO)) VALUE(6)
CALLPRC PRC(CEETSTA) PARM(&p6 &PARMNO *OMIT)

/* set value from optional passed parms */
IF COND(%BIN(&P4) *EQ 1) THEN(DO)
CHGVAR VAR(&PMVM) VALUE(&pPMVM)
ENDDO
IF COND(%BIN(&P5) *EQ 1) THEN(DO)
CHGVAR VAR(&ACB ) VALUE(&pACB )
ENDDO
IF COND(%BIN(&P6) *EQ 1) THEN(DO)
CHGVAR VAR(&DIPD) VALUE(&pDIPD)
ENDDO





-----Oprindelig meddelelse-----
Fra: MIDRANGE-L [mailto:midrange-l-bounces@xxxxxxxxxxxx] På vegne af Roger
Harman
Sendt: 16. marts 2017 00:34
Til: Midrange Systems Technical Discussion
Emne: Optional parameters in CLLE

I have a couple of processes where I'd like to have one or two optional
parms.

In the past, I've just tried using them in a CHGVAR and monitor for MCH3601.

But... I'm wondering if %address() can be used instead. I think it would
be cleaner. In my testing, I've seen hex zeros for the %address of a
non-passed parm. That seems to indicate a *NULL will be returned. Since
it's consistent and not a garbage address, I would think I could count on
that logoc.

Does anyone know if this is a documented behavior? I haven't found a
definitive answer.

Thanks.

Roger Harman
COMMON Certified Application Developer - ILE RPG on IBM i on Power

 
 

--
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: http://lists.midrange.com/mailman/listinfo/midrange-l
or email: MIDRANGE-L-request@xxxxxxxxxxxx Before posting, please take a
moment to review the archives at http://archive.midrange.com/midrange-l.

Please contact support@xxxxxxxxxxxx for any subscription related questions.

Help support midrange.com by shopping at amazon.com with our affiliate link:
http://amzn.to/2dEadiD


As an Amazon Associate we earn from qualifying purchases.

This thread ...

Follow-Ups:
Replies:

Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2024 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.