OR

The OR operator is the logical union operator.

Syntax

bool-expr OR bool-expr
  1. bool-expr is a boolean expression.

Usage

The OR operator is used to perform a logical disjonction on two boolean expressions.

Possible values of the operands are TRUE, FALSE and NULL. If one of the operands is NULL, the logical OR expression evaluates to NULL or TRUE, depending on the value of the second operand:
  • The result of OR is FALSE, if both operands are FALSE.
  • The result of OR is TRUE, if one of the operands is TRUE and the other operand is TRUE, FALSE or NULL.
  • The result of OR is NULL, if one of the operands is NULL and the other operand is NULL or FALSE.

By default, the runtime system evaluates both operands on the left and right side of the OR keyword. This is the traditional behavior of the Genero language, but in fact the right operand does not need to be evaluated, if the first operand evaluates to TRUE. This method is called short-circuit evaluation, and can be enabled by adding the OPTIONS SHORT CIRCUIT clause at the beginning of the module.

Example

MAIN
    DISPLAY "T|T: ", NVL( TRUE OR TRUE, "NULL" )
    DISPLAY "T|F: ", NVL( TRUE OR FALSE, "NULL" )
    DISPLAY "T|N: ", NVL( TRUE OR NULL, "NULL" )
    DISPLAY "F|T: ", NVL( FALSE OR TRUE, "NULL" )
    DISPLAY "F|F: ", NVL( FALSE OR FALSE, "NULL" )
    DISPLAY "F|N: ", NVL( FALSE OR NULL, "NULL" )
    DISPLAY "N|T: ", NVL( NULL OR TRUE, "NULL" )
    DISPLAY "N|F: ", NVL( NULL OR FALSE, "NULL" )
    DISPLAY "N|N: ", NVL( NULL OR NULL, "NULL" )
END MAIN
Output:
T|T:      1
T|F:      1
T|N:      1
F|T:      1
F|F:      0
F|N: NULL
N|T:      1
N|F: NULL
N|N: NULL