The WFL jobs in the examples presented thus far have been set up to execute statements in sequential order. However, WFL also enables you to execute statements conditionally or repeatedly by using flow-of-control statements. The flow-of-control statements include:
-
IF
-
DO
-
WHILE
-
CASE
-
GO
The IF statement executes a certain statement only if the value of a particular Boolean expression is TRUE.
The DO statement and the WHILE statement are both used to cause repeated execution of a statement or set of statements. Both statements evaluate a Boolean expression before each repetition is initiated, to decide whether to do it again. The DO statement differs from the WHILE statement in that it checks the Boolean expression at the end of the loop instead of at the start; the statements included in the loop are therefore guaranteed to execute at least once.
The CASE statement chooses one of several possible alternative actions, depending on the value of the variable or case expression that follows the word CASE.
Whenever the syntax of a flow-of-control statement calls for a statement to be included, that statement can be another flow-of-control statement. Therefore, flow-of-control statements can be nested to form complex flow-of-control structures.