Work with logical data
- Last Updated: January 31, 2022
- 2 minute read
- OpenEdge
- Version 13.0
- Documentation
Logical data represents a binary value—YES (TRUE) or NO (FALSE). You use logical values and expressions in many parts of your application. Many functions, methods, and procedures return values that report the success or failure of their execution. In your ABL code, you typically check a return value to determine how to continue execution.
When you define a logical variable, you can initialize it. The possible values are YES, NO, TRUE, or FALSE. YES is the same as TRUE, and NO is the same as FALSE. If you do not initialize the variable when you define it, then the default initial value is NO.
Logical expressions
A logical expression can contain a combination of comparison and logical
operators. The comparison operators include <, >, <=, >=, and =. In
addition, ABL provides the logical operators AND,
OR, and NOT.
| Operator | Example | Explanation |
|---|---|---|
| AND | CreditLimit = 1000 AND Country = "USA" |
Checks whether the CreditLimit is
1000 and the Country is
USA. |
| OR | Country = "UK" OR Country = "USA" |
Checks whether the Country is either
UK or USA. |
| NOT | (NOT (Balance = 0)) AND Country = "USA" |
Checks whether the Balance is not zero and the
Country is USA. |
|
|
Precedence of operators
As with numeric expressions, a logical expression also has a precedence of operators. A best practice is to use parentheses to explicitly control the order of evaluation of a logical expression, just as you do for numeric expressions.
AND and NOT.
|
Logical operators containing expressions that evaluate
to the Unknown value (?)
AND,
OR, NOT):- For an
ANDoperation, the result is FALSE if either operand evaluates to FALSE (even if one of the operands is the Unknown value (?)). - For an
ORoperation, the result is TRUE if either operand evaluates to TRUE (even if one of the operands is the Unknown value (?)). - In all other cases, the result is the Unknown value (
?) if an operand evaluates to the Unknown value (?).