Conditional Logic
Once the CONSTRUCT statement is completed, you must test whether the
INT_FLAG was set to TRUE (whether the user canceled
the dialog). Genero BDL provides the conditional logic statements IF or
CASE to test a set of conditions.
The IF statement
The IF instruction executes a group of statements
conditionally.
IF <condition> THEN
...
ELSE
...
END IF
IF statements can be nested. The ELSE clause may be
omitted.
TRUE, the runtime system executes the block of statements
following THEN, until it reaches either the ELSE keyword or the
END IF keywords. Your program resumes execution after END IF. If
condition is FALSE, the runtime system executes the block of statements between
ELSE and END
IF.IF (INT_FLAG = TRUE) THEN
LET INT_FLAG = FALSE
LET cont_ok = FALSE
ELSE
LET cont_ok = TRUE
END IFThe CASE statement
The CASE statement specifies statement blocks to be executed
conditionally, depending on the value of an expression.
IF statements, CASE does not restrict the logical flow
of control to only two branches. Particularly if you have a series of nested IF
statements, the CASE statement may be more readable. In the previous example, the
CASE statement could have been substituted for the IF
statement:CASE
WHEN (INT_FLAG = TRUE)
LET INT_FLAG = FALSE
LET cont_ok = FALSE
OTHERWISE
LET cont_ok = TRUE
END CASEvar1:CASE var1
WHEN 100
CALL routine_100()
WHEN 200
CALL routine_200()
OTHERWISE
CALL error_routine()
END CASEThe first WHEN condition in the CASE statement will be
evaluated. If the condition is true (var1=100), the statement block is executed and the
CASE statement is exited. If the condition is not true, the next
WHEN condition will be evaluated, and so on through subsequent
WHEN statements until a condition is found to be true, or
OTHERWISE or END CASE is encountered. The
OTHERWISE clause of the CASE statement can be used as a catchall
for unanticipated cases.
See Flow Control for other examples of IF and CASE syntax and
the additional conditional statement WHILE.