Contents - Index


 

Use the ProcIf command within a procedure to only process the next line in the procedure if a specified condition is true.  If the condition is not true, the following line will be ignored.

 

ProcIf may also be entered as If.

 

Required Operands

 

OPER1 is the name of a previously declared variable.

 

COND is the condition to test for.  One of the following must be specified:

 

        LT    less than

        LE    less than or equal

        EQ    equal

        NE    not equal

        GE    greater than or equal

        GT    greater than

 

 

OPER2 is a value.  If the OPER1 variable is of type numeric, OPER2 must be an unsigned integer.

 

If the OPER1 variable has type CHAR, its value is compared alphamerically with the OPER2 value.  If the two comparison values are not the same length, the shorter one is padded on the right with blanks to cause the lengths to be the same.

 

If the OPER1 variable has type NUM, the comparison is performed algebraically.

 

Use the ProcIfD command to directly compare the values of two variables.

 

Nested ProcIf commands are not supported but can easily be simulated with a combination of ProcIfs and ProcGotos.

 

Notes

 

The ProcIf command syntax is not symmetrical.  It compares a VARIABLE on the left with a VALUE on the right.  Thus, the following commands will be treated as noted in the comments:

 

           IF X EQ 3       ;COMPARE THE VALUE OF X TO 3

           IF X EQ &Y      ;COMPARE THE VALUE OF X TO THE VALUE OF Y

                           ; IFD X EQ Y SHOULD BE USED INSTEAD

           IF 3 EQ &Y      ;INVALID - 3 IS NOT A VARIABLE NAME

           IF X EQ Y       ;COMPARE THE VALUE OF X TO THE CHARACTER Y

           IF &X EQ &Y     ;VALID ONLY IF THE VALUE OF X

                           ; IS THE NAME OF A VARIABLE

                           ;THEN COMPARES THE VALUE OF THAT VARIABLE (I.E. THE VALUE

                           ;OF THE VALUE OF X) TO THE VALUE OF Y

 

 

 

When you use the ProcIf command to compare the value of OPER1 to an OPER2 value supplied by variable replacement using the ampersand (&), you should place OPER2 in quotes if it might contain characters such as blank, comma, or equal sign that would confuse the scan.  Thus, you would use

 

           IF X EQ '&Y.K'

(You should also set PPDLITEX to 1 and PPDLITDL to '''' if there is any possibility that Y can contain a single quote character.)

 

Return Codes

 

The ProcIf command does not change the return code.

 

Examples

 

If variable DEST is equal to blanks, exit the procedure with an error message:

 

 ------------------------------------------------------------------------

 DECLARE MEM,CHAR,33,V

 DECLARE DEST,CHAR,4,V

 PARSE MEM,DEST

 IF DEST,EQ,''

     EXIT SV,'(OMPRLSTA) ** OPERAND "DEST" IS REQUIRED **'

 ------------------------------------------------------------------------