On 12 Apr 2013 14:11, Stone, Joel wrote:
I would like to build a command to return sysName and libName.

But, I would like the variables to be optional when using the
command.

Examples:

Command name is GetEnvr

I would like the following to be functional:

GetEnvr (&sysname) (&libname)

GetEnvr () (&libname)

It appears that if I want to return a value, then the value MUST be
used in every call of the command. Is it possible to make a return
variable optional?

//bchjob jobd(one_with_a_user) job(getenvrtst)
//DATA GETENVR *SRC
CMD
PARM KWD(SYS) TYPE(*CHAR) LEN(10) MIN(0) MAX(1) RTNVAL(*YES)
PARM KWD(LIB) TYPE(*CHAR) LEN(10) MIN(0) MAX(1) RTNVAL(*YES)
//
//DATA GETENVRCPP
pgm parm(&sys &lib)
dcl &sys *char 10
dcl &lib *char 10

parmSYS:
rtvneta sysname(&sys)
monmsg mch3601 exec(do)
rcvmsg (*same (*)) *pgmq *excp *n 0 rmv(*yes)
goto postSYS
enddo
postSYS:

parmLIB:
rtvobjd *libl/prodfile *file rtnlib(&lib)
monmsg mch3601 exec(do)
rcvmsg (*same (*)) *pgmq *excp *n 0 rmv(*yes)
enddo
monmsg (cpf9800) exec(chgvar &lib '*NOPROD')
/* maybe rmv or mov the error message */
postLIB:
return
//
//DATA GETENVRTST
dcl &ij *char 01
dcl &sysname *char 10
dcl &libname *char 10
rtvjoba type(&ij)
chgvar &sysname 'junk'
chgvar &libname 'junk'
getenvr &sysname &libname
dmpclpgm
if (&ij *eq '1') then(do)
dspsplf qppgmdmp splnbr(*last)
dltsplf qppgmdmp splnbr(*last)
enddo

chgvar &sysname 'junk'
chgvar &libname 'junk'
getenvr () &libname
dmpclpgm
if (&ij *eq '1') then(d0)
dspsplf qppgmdmp splnbr(*last)
dltsplf qppgmdmp splnbr(*last)
enddo
//
crtclpgm getenvr srcfile(getenvrcpp)
crtcmd getenvr getenvr srcfile(getenvr) allow(*ipgm *bpgm *irexx *brexx)
crtclpgm getenvrtst srcfile(getenvrtst)
chgjob logclpgm(*yes)
call getenvrtst
dspjoblog output(*print)
//endbchjob


As an Amazon Associate we earn from qualifying purchases.

This thread ...

Follow-Ups:

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.