Glenn Wants To Know More Facts About Special Values
November 28, 2012 Hey, Ted
I found your article 10 Facts You Should Know about Special Values very interesting. I have a few questions related to a command I am writing.
I owe Glenn an apology. He is one of the many people whose email I never responded to. I’m sorry, Glenn. Sometimes life presents too many opportunities.
Here’s Glenn’s first question:
1. If a user specifies *ALL for a parameter, how do you prevent the user from typing in other values?
Fair enough. Define *ALL in the Single Value (SNGVAL) keyword, not in the Special Value (SPCVAL) keyword.
CMD PROMPT('Do it') PARM KWD(RPTTYPE) TYPE(*DEC) LEN(1) RSTD(*YES) + DFT(*ALL) + SPCVAL((*CVNPRB 1) (*LIBSUM 2) (*LIBDTL 3) + (*OBJSUM 4) (*OBJDTL 5)) + SNGVAL((*ALL 0)) + MIN(0) MAX(5) + PROMPT('Type of report')
Now you can run commands like these:
DOIT RPTTYPE(*ALL) DOIT RPTTYPE(*LIBSUM *OBJSUM) DOIT RPTTYPE(*CVNPRB *LIBSUM *LIBDTL *OBJSUM *OBJDTL)
But do this. . .
DOIT RPTTYPE(*ALL *LIBSUM)
. . .and you’ll get error CPD0094 (*ALL must be only value for parameter RPTTYPE).
Now, Glenn’s second question:
2. Can you prevent a user from keying in the same value more than once?
No. Nothing will stop you from doing this:
DOIT RPTTYPE(*LIBSUM *LIBSUM *LIBSUM *LIBSUM *LIBSUM)
The system allows you to enter up to five values in the RPTTYPE parameter. If you want to waste a spot by duplicating a value, the system won’t object. It is up to the command-processing program to recognize and ignore duplicates.
Glenn had two more questions, both of which deal with mixed lists. That will have to be a topic for another day.