IF/ENDIF Examples
Example 1:
|
|
|
|
|
|
|
|
|
|
|
|
The message "F1 was hit" is not displayed unless the F1 (Function Key 1) Function Flag is TRUE.
Example 2:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
The message "F1 was hit" is displayed if the F1 (Function Key 1) Function Flag is TRUE. If any other Function or Control Key was struck the message "Another Function or Control Key was hit" is displayed. Otherwise, the message "No Function or Control Key was hit" is displayed.
Example 3:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
The message "F1 was hit" is displayed if the F1 (Function Key 1) Function Flag is TRUE. The message "F2 was hit" is displayed if the F2 (Function Key 2) Function Flag is TRUE. If any other Function or Control Key was struck the message "Another Function or Control Key was hit" is displayed. Otherwise, the message "No Function or Control Key was hit" is displayed.
Example 4:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
If the result of dividing '5' into RESULT is 10, the message "RESULT equal to 10" is displayed. Otherwise, the message "RESULT not equal to 10" is displayed.
Example 5:
Another way of accomplishing the above test would be:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
This saves one PL/B instruction and checks the same conditions. However, RESULT does not contain the modified value after this instruction.
Example 6:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
The message "VALID ANSWER" is displayed if the variable DIM1 is equal to 'A' or 'B'. Else, the message "INVALID ANSWER" is displayed.
Example 7:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
The message "VALID ANSWER is displayed if DIM1 is equal to 'A' and FORM2 is equal to '0' or if DIM2 is equal to 'B' and FORM2 is equal to 1.
Example 8:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
If the expression (A+B/10) is not equal to zero, the message "NOT ZERO" is displayed. Otherwise, the message "ZERO" is displayed.
![]() |