IF/THEN/ELSE/ENDIF
You can use this function to perform a comparison to see whether the condition tested is true or false. If the condition is true, the statements following the IF/THEN statement are executed until the ELSE of the ENDIF function is detected. If an ELSE is detected, the instructions following the ELSE are ignored until the ENDIF function is detected. If the condition is false, the statements following the IF/THEN function are ignored until an ELSE or ENDIF is detected. If ELSE is detected, the instructions following the ELSE are executed until the ENDIF is detected.
The format of this function is IF operand1 condition operand2 THEN. Both operand1 and operand2 must be of the same variable type (that is to say both are numeric or both are characters).
If the operand detected in an IF statement is a GOTO function, the IF clause is terminated in the same manner that the ENDIF terminates the IF function. Execution continues at the statement following the routine specified by the GOTO function.
The syntax rules of this function are as follows:
- The first line must contain the IF statement, condition to be tested, and the THEN statement.
- The ELSE statement must be on a line with no other statements.
- Valid conditions include greater than (>), less than (<), and equal to (=) .
- Operands can be tested for one or more conditions.
- The IF function is ended by the ENDIF statement.
- Character data specified in operand1 or operand2 must be enclosed in double quotation marks.
IF %RC > 0 THEN SET %FAIL = %FAIL + 1 SAY Request failed RC=%RC ELSE SET %GOOD = %GOOD + 1 SAY Request Successful ENDIF
IF %WTORREPLY <> “C” THEN EXIT 32 ELSE NOOP ENDIF