Boolean Binary Operators

JADE provides standard operators that take Boolean values as operands and produce a Boolean result. These operators include the logical:

Applying relational operators to operands of other types can also produce Boolean values. The following table lists the action and resulting values of the and, or, and not operators.

p q p and q p or q not p
false false false false true
false true false true true
true false false true false
true true true true false

Boolean expressions involving the and or the or operators are conditionally evaluated; that is, in the expression a and b, b is not evaluated if a is false.

In the expression a or b, b is not evaluated if a is true. This may be important in some cases where a and b are methods with side effects.

and Operator

The syntax of the and operator is:

boolean-expression and boolean-expression

The code fragment in the following example shows the use of the and operator.

if newManager = null and newCompany.allEmployees.size > 0 then
    app.msgBox("A manager is required", "Error", MsgBox_OK_Only);
    return;
endif;
not Operator

The syntax of the not operator is:

not boolean-expression

The code fragment in the following example shows the use of the not operator.

if not file.isOpen then
    app.msgBox("File is not open", "Error", MsgBox_OK_Only);
    return;
endif;
or Operator

The syntax of the or operator is:

boolean-expression or boolean-expression

The code fragment in the following example shows the use of the or operator.

if newLevel < 1 or newLevel > 5 then
    app.msgBox("Invalid level", "Error", MsgBox_OK_Only);
    return;
endif;