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 the boolean condition is 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 THEN
  LET int_flag = FALSE
  LET cont_ok = FALSE
ELSE
  LET cont_ok = TRUE
END IF

The ELSE clause may be omitted

The CASE statement

The CASE statement specifies statement blocks to be executed conditionally, depending on the value of an expression.

Unlike 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
  LET int_flag = FALSE
  LET cont_ok = FALSE     
OTHERWISE
  LET cont_ok = TRUE 
END CASE
Usually, there would be several conditions to check. The following statement uses an alternative syntax, since all the conditions check the value of var1:
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.