You can combine two or more conditional expressions on the IF statement. ISPF evaluates the conditional expressions on the IF statement from left to right, starting with the first expression and proceeding to the next and subsequent expressions on the IF statement until processing is complete.
The use of the AND Boolean operator takes precedence over the OR Boolean operator as shown in these examples.
The number of conditional expressions you can specify on the IF statement is limited to 255.
AND processing returns a TRUE result for the IF statement only if all the conditional expressions evaluate as TRUE.
OR processing returns a TRUE result for the IF statement if any of the conditional expressions evaluate as TRUE. Also, for an IF statement to be evaluated as FALSE, all conditional expressions must be evaluated as FALSE.
The Boolean operators must be separated by a preceding and following blank or blanks.
IF (VER (&vara,NB,ALPHA) & VER (&varb,NB,ALPHA))
⋮
ELSE
IF (&varc = 123 OR VER (&vard,NB,NUM))
⋮
The first IF statement will be successful only if both VER expressions are satisfied, while the IF statement under the ELSE will be successful if either of the expressions on the IF statement are satisfied.
IF (VER (&vara,NB,ALPHA) & VER (&varb,NB,ALPHA) &
&varc = abc,xyz | &vard = 123 | &vard = 456)
⋮
ELSE
.msg = nld123
The IF statement will be successful if the comparisons of the first three expressions evaluate to TRUE, or if expressions four or five evaluate to TRUE.
IF (VER (&vara,NB,ALPHA) AND &varb = abc OR
VER (&vara,NB,ALPHA) AND &varb = xyz)
⋮
ELSE
.msg = nld124
.attr (vara) = 'color(yellow)'
.attr (varb) = 'color(yellow)'
Either of the pairs of expressions must evaluate to TRUE to achieve a successful IF statement.
IF (Expression-1 OR Expression-2 AND Expression-3)
⋮
ELSE
.msg = nld125
Because the IF statement AND Boolean operator has precedence over the IF statement OR Boolean operator, specifying an IF statement similar to the one shown might not give you the results you expected.
IF ( (expression1 OR expression2) AND expression3)
You
would need to write either two separate IF statements: IF (Expression-1 OR Expression-2)
IF (Expression-3)
⋮
Else
.msg = nld126
Or two separate comparison pairs: IF (Expression-1 AND Expression-3 OR
Expression-2 AND Expression-3)
⋮
Else
.msg = nld127