Use the ProcIfThen command within a procedure to process following lines in the procedure if a specified condition is true. If the condition is not true, the following lines will be ignored until the related ProcElse or ProcEndIf command is encountered.
ProcIfThen may also be entered as IfThen.
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 IFTHEN commands are supported up to 16 levels.
Notes
The ProcIfThen 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 ProcIfThen 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 ProcIfThen command does not change the return code.
Examples
The following example shows the ProcIfThen command used within a procedure.
------------------------------------------------------------------------
DECLARE MEM,CHAR,33,V
DECLARE DEST,CHAR,4,V
PARSE MEM,DEST
IFTHEN DEST,EQ,'LIBR'
-
-
IFTHEN SIBUSER EQ LARS
SET MEM ACCT1
-
ENDIF
-
-
ENDIF
------------------------------------------------------------------------