Search code examples
commandibm-midrange

How to create a command that will allow a value and range at the same time


Not sure how to call it but I'm creating a command (CRTCMD) to compile it. I wanted to achieve this in my command when F4 is pressed:

Test . . . . . . . . . . .   *ALL          1-8, *ALL

I tried all of this but it will either have an error or the desired outcome is wrong.

PARM KWD(TEST) TYPE(*DEC) LEN(06) RSTD(*YES) + 
      PROMPT('Test') VALUES(*ALL *RANGE(1 8)) 
PARM KWD(TEST) TYPE(*DEC) LEN(06) RSTD(*YES) +
      PROMPT('Test') VALUES(*ALL *RANGE 1 8)  
PARM KWD(TEST) TYPE(*DEC) LEN(06) RSTD(*YES) +
      PROMPT('Test') VALUES(*ALL 1-8)
PARM KWD(TEST) TYPE(*DEC) LEN(06) +
      PROMPT('Test') RANGE(1 8)
PARM KWD(TEST) TYPE(*DEC) LEN(06) RSTD(*YES) +
      PROMPT('Test')VALUES(*ALL) RANGE(1 8)

Solution

  • You have to use RANGE and SPCVAL like below

    • RANGE will restrict values to a range
    • SPCVAL keyword will make special value *ALL available, 0 will be sent to the program
       PARM       KWD(TEST) TYPE(*DEC) LEN(6) RANGE(1 8) +
             SPCVAL((*ALL 0)) PROMPT('Test')
    

    *ALL can be used as default

       PARM       KWD(TEST) TYPE(*DEC) LEN(6) DFT(*ALL) RANGE(1 8) +
             SPCVAL((*ALL 0)) PROMPT('Test')    
    

    This is what I get :

    Test . . . . . . . . . . . . . .   *ALL          1-8, *ALL