Difference between revisions of "OptionalParameters"

From MidrangeWiki
Jump to: navigation, search
Line 2: Line 2:
  
 
One must use the CEETSTA procedure to know if the parameter has been passed.   
 
One must use the CEETSTA procedure to know if the parameter has been passed.   
This can be created using CRBNDCL since all CEE APIs are bound in by default.
+
This can be created using CRTBNDCL since all CEE APIs are bound in by default.
  
 
             PGM        PARM(&PARM1 &PARM2)                           
 
             PGM        PARM(&PARM1 &PARM2)                           

Revision as of 15:31, 27 September 2007

ILE CL programs can accept optional parameters.

One must use the CEETSTA procedure to know if the parameter has been passed. This can be created using CRTBNDCL since all CEE APIs are bound in by default.

            PGM        PARM(&PARM1 &PARM2)                          
                                                                                       
            DCL        VAR(&PARM1) TYPE(*CHAR) LEN(3)                                
            DCL        VAR(&PARM2) TYPE(*CHAR) LEN(3)                                
            DCL        VAR(&PARMRESULT) TYPE(*INT) LEN(4)                              
            DCL        VAR(&PARMNUMBER) TYPE(*INT) LEN(4)                              
                                                                                       
            CHGVAR     VAR(&PARMNUMBER) VALUE(1)                                       
            CALLPRC    PRC(CEETSTA) PARM(&PARMRESULT &PARMNUMBER *OMIT)                
            IF         COND(&PARMRESULT *EQ 1) THEN(DO)                                
               CALL PGM(PROGRAM2) PARM(&PARM1 &PARM2)              
            ENDDO                                                                      
            ELSE       CMD(DO)
               CALL PGM(PROGRAM2) PARM(&PARM1)              
            ENDDO                                                                      
                                                                                       
            ENDPGM