Tutorial Chapter 4: Query by Example / Allowing the User to Cancel the Query Operation |
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 instruction executes a group of statements conditionally.
IF <condition> THEN ... ELSE ... END IF
IF statements can be nested. The ELSE clause may be omitted.
IF (INT_FLAG = TRUE) THEN LET INT_FLAG = FALSE LET cont_ok = FALSE ELSE LET cont_ok = TRUE END IF
The CASE statement specifies statement blocks to be executed conditionally, depending on the value of an expression.
CASE WHEN (INT_FLAG = TRUE) LET INT_FLAG = FALSE LET cont_ok = FALSE OTHERWISE LET cont_ok = TRUE END CASE
CASE var1 WHEN 100 CALL routine_100() WHEN 200 CALL routine_200() OTHERWISE CALL error_routine() END CASE
The 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.