Relational operators in PocketBuilder

Description

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.

Table 4-2: PocketBuilder relational and logical operators

Operator

Meaning

Example

=

Equals

if Price=100 then Rate=.05

>

Greater than

if Price>100 then Rate=.05

<

Less than

if Price<100 then Rate=.05

<>

Not equal

if Price<>100 then Rate=.05

>=

Greater than or equal

if Price>=100 then Rate=.05

<=

Less than or equal

if Price<=100 then Rate=.05

NOT

Logical negation

if NOT Price=100 then Rate=.05

AND

Logical and

if Tax>3 AND Ship <5 then Rate=.05

OR

Logical or

if Tax>3 OR Ship<5 then Rate=.05

Usage

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”.

Examples

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