Numeric Logical Operators
Logical operators are used to construct complex commands which ultimately evaluate to one or zero. Most logical operations take the form (left_expression) (operator) (right_expression), similar to mathematical expres- sions such as 1 + 2. The exception is the not operator "!" which takes only a single argument, of the form ! (right_expression). The logical operators use the convention that zero is "false" and any non-zero value is "true". The not operator returns 1 (true) if the (right_expression) is 0 (false) and returns 0 (false) if (right_expression) is non-zero (true). One common use of the not operator is in IF commands such as:
IF !x THEN PRINT "x is zero."
The other logical operators can be also be used as part of the argument in IF commands. For example, an IF command may contain two conditions which must both be true for the THEN command to be executed:
IF ( x > 1 ) & ( y < 2 ) THEN PRINT "Both conditions are true."
These two conditions are related by an "and" expression denoted by &. Note the parentheses are used to force precedence. ZPL supports the logical operators described in the following table.
NUMERIC LOGICAL OPERATORS
| Logical | Description |
| & | And, returns 1 only if both expressions are non-zero. |
| | | Or, returns 1 if at least one expression is non-zero. |
| ^ | Xor, returns 1 if only one expression is non-zero. |
| ! | Not, returns 0 if (right_expression) is non-zero, else returns 1. |
| == | Equality, returns 1 if expressions are equal. |
| > | Greater than, returns 1 if left_expression is greater than right_expression. |
| < | Less than, returns 1 if left_expression is less than right_expression. |
| >= | Greater than or equal to, returns 1 if left_expression is greater than or equal to right_expression. |
| <= | Less than or equal to, returns 1 if left_expression is less than or equal to right_expression. |
| != | Inequality, returns 1 if expressions are unequal. |
Next: