<< Click to Display Table of Contents >> Navigation: User guide > Logic > Logical operator |
This represents an operator to be used when constructing a logical expression from more than one test. There are four logical operators:
+ Or (either or both). The result is true if either the result so far is true or the next test is true or both are true. The result is false if both the result so far and the next test are false.
. And (both). The result is true if both the result so far and the next test are true. The result is false if either the result so far is false or the next test is false or both are false.
* Difference (either or both). The result is true if the result so far differs from the next test, that is if one is true and the other is false.
= Same (neither or both). The result id true if the result so far is the same as the next test, that is if both are false or both are true. The result is false if one is true and the other is false.
N Not. Is only ever applied to a particular test or a number of tests within parentheses.
IMPORTANT: CL always works from left to right when evaluating expressions unless parentheses are uses to control the evaluation.
Without parentheses you need to be careful when mixing "and" and "or" together, as in the examples below:
$fred/1 . $class/5+9,
is equivalent to:
($fred/1 . $class/5) + $class /9,
and
$643/4+5 . 6+7,
is equivalent to:
(($643/4 + $643/5) . $643/6) + $643/7,
and
$132/4+$133/nv.n3,
is equivalent to:
($132/4 + $133/nv) . $133/n3,
But masks or ranges are treated as one test:
$643/45.6..7,
is equivalent to:
$643/(4+5) . (6..7)
and
$132/4+$133/nv3
means:
$132/4 + $133/(nv . n3)
Examples of logical operator usage:
$a/n5+6 (not 5) or 6
$a/n5..7.n9 (not (any 5 through 7 inclusive)) and (not 9)
$a/5=6 (5 and 6) or (not 5 and not 6)
$a/4*9 (4 and not 9) or (9 and not 4)
$a/n45.6 not (4 or 5) and 6
$a/5..7.nl..4 (any 5 through 7 inclusive) and not (any 1 through 4 inclusive)
$a/4 + (5.8) 4 or (5 and 8)
$a/n (5+7) not (5 or 7), same as (not 5) and (not 7)
$a/n (5.7) not (5 and 7), same as (not 5) or (not 7)
n($a/5+6) not (5 or 6), same as (not 5) and (not 6)