PocketBuilder uses relational operators in boolean expressions to evaluate two or more operands. Logical operators can join relational expressions to form more complex boolean expressions.
The result of evaluating a boolean expression is always true or false.
The following table lists relational and logical operators.
Operator |
Meaning |
Example |
---|---|---|
= |
Equals |
|
> |
Greater than |
|
< |
Less than |
|
<> |
Not equal |
|
>= |
Greater than or equal |
|
<= |
Less than or equal |
|
NOT |
Logical negation |
|
AND |
Logical and |
|
OR |
Logical or |
|
Comparing strings When PocketBuilder compares strings, the comparison is case sensitive. Trailing blanks are significant.
For information on comparing strings regardless of case, see the functions Upper and Lower.
To remove trailing blanks, use the RightTrim function. To remove leading blanks, use the LeftTrim function. To remove leading and trailing blanks, use the Trim function. For information about these functions, see RightTrim, LeftTrim, and Trim.
Null value evaluations When you form a boolean expression that contains a null value, the AND and OR operators behave differently. Thinking of null as undefined (neither true nor false) makes the results easier to calculate.
For more information about null values, see “NULL values”.
Case-sensitive comparisons If you compare two strings with the same text but different case, the comparison fails. But if you use the Upper or Lower function, you can ensure that the case of both strings are the same so that only the content affects the comparison:
City1 = "Austin"
City2 = "AUSTIN"
IF City1 = City2 ... // Returns FALSE
City1 = "Austin"
City2 = "AUSTIN"
IF Upper(City1) = Upper(City2)... // Returns TRUE
Trailing blanks in comparisons In this example, trailing blanks in one string cause the comparison to fail:
City1 = "Austin"
City2 = "Austin "
IF City1 = City2 ... // Returns FALSE
Logical expressions with null values In this example, the expressions involving the variable f, which has been set to null, have null values:
boolean d, e = TRUE, f
SetNull(f)
d = e and f // d is NULL
d = e or f // d is TRUE