- Use
- Rules
- Notes
- Numeric variable
- String variable
- Priority
The logical operators are as follows: | | | Logical multiplication. The conditions made of AND are entirely evaluated (even if the first condition is false). | | Logical multiplication. The conditions made of _AND_ are evaluated in an optimized way. If the first part of the expression is false, the rest of the expression is not evaluated. | | Logical addition. The conditions made of OR are entirely evaluated (even if the first condition is true). | | Logical addition. The conditions made of _OR_ are evaluated in optimized way. If the first part of the expression is true, the rest of the expression is not evaluated. | | Logical negation. |
The logical operators are used to perform logical operations and to build conditions.
IF Customer.City = "Montpellier" AND Customer.Title = "Mr" THEN ManMontpellier ++ // Number of men living in Montpellier END IF Customer.City = "Montpellier" OR Customer.City = "Lyon" THEN MontpellierLyon ++ // Number of customers living in Montpellier, // or in Lyon END
True AND True: returns TrueTrue AND False: returns False True OR True: returns True True OR False: returns True NOT True: returns False Numeric variable If a numeric variable is handled like a logical operator (boolean), "0" is equivalent to False. Any other value is equivalent to True. For example, the two following lines of code are equivalent: The first syntax (IF TestNum THEN) should be preferred to the second one. String variable A WLanguage error will occur if a string variable is handled like a logical operator. For example, the syntax: "IF StrTest THEN" will return an error at run time (but not when the project is compiled). Priority The AND and OR, _AND_ and _OR_ operators have the same priority. To give priorities to these operators, all you have to do is use brackets. For example:
IF (A = 2 AND B > 3) OR (A = 2 AND B < 0) THEN ...
Exceptions: - In SQL filters and queries, the AND operator takes precedence over the OR operator.
For example:
Condition1 AND Condition2 OR Condition3
will be evaluated as follows:
(Condition1 AND Condition2) OR Condition3
- The optimized logical addition _OR_ must not be used if one of the expressions to compare is using the result of a function that may return NULL.
For example, the following comparison:
IF CallFunction() = "Value1" _OR_ CallFunction() = "Value2" THEN...
will have to be replaced with the following code if CallFunction can return the NULL value:
IF CallFunction() = "Value1" OR CallFunction() = "Value2" THEN...
This page is also available for…
|
|
|
|