Language basics / Expressions |
A boolean expressions evaluates to an INTEGER value that can be TRUE, FALSE and in some cases, NULL.
MAIN DEFINE r, c INTEGER LET c = 4 LET r = ( c!=5 ) AND ( c==2 OR c==4 ) IF ( r AND canReadFile("config.txt") ) THEN DISPLAY "OK" END IF END MAIN
Boolean expressions are a combination of logical operators and boolean comparison operators such as ==, >= or !=. The result type of a boolean expression is an INTEGER. Any integer value different from zero is defined as true, while zero is defined as false. You can use an INTEGER or a BOOLEAN variable to store the result of a boolean expression.
MAIN DEFINE b BOOLEAN LET b = ( "a" == "b" ) -- result is FALSE (0) END MAIN
If an expression that returns NULL is the operand of the IS NULL operator, the value of the boolean expression is TRUE.
MAIN DEFINE r INTEGER LET r = NULL IF r IS NULL THEN DISPLAY "TRUE" END IF END MAIN
If you include a boolean expression in a context where the runtime system expects a number, the expression is evaluated, and is then converted to an integer by the rules TRUE=1 and FALSE=0.
MAIN DEFINE r INTEGER LET c = 4 LET r = 4 + (1==0) -- result is 4. END MAIN
The boolean expression evaluates to TRUE if the value is a non-zero real number or any of the following items:
If a boolean expression includes an operand whose value is not an integer data type, the runtime system attempts to convert the value to an integer according to the data conversion rules.
A boolean expression evaluates to NULL if the value is NULL and the expression does not appear in any of the following contexts:
The syntax of boolean expressions in programs is not the same as Boolean conditions in SQL statements.
Boolean expressions in CASE, IF, or WHILE statements return FALSE if any element of the comparison is NULL, except for operands of the IS NULL and the IS NOT NULL operator.