BEA Logo BEA Tuxedo Release 8.0

  BEA Home  |  Events  |  Solutions  |  Partners  |  Products  |  Services  |  Download  |  Developer Center  |  WebSUPPORT

 

   Tuxedo Documentation   |   Programming BEA Tuxedo ATMI Applications Using FML   |   Local Topics   |   Previous Topic   |   Next Topic   |   Contents

 


Description of Boolean Primary Expressions

Boolean expressions are built from primary expressions, which can be any of the following:

A field name or a field name followed by a subscript is a primary expression. The subscript indicates which occurrence of the field is being referenced. The subscript may be either an integer constant, or ? indicating any occurrence; the subscript cannot be an expression. If the field name is not subscripted, field occurrence 0 is assumed.

If a field name reference appears without an arithmetic, unary, equality, or relational operator, then its value is the long integer value 1 if the field exists and 0 if the field does not exist. This may be used to test the existence of a field in the fielded buffer regardless of field type. (Note that there is no * indirection operator.)

A constant is a primary expression. Its type may be long, double, or carray, as discussed in the conversion section.

A parenthesized expression is a primary expression for which the type and value are identical to those of the unadorned expression. Parentheses may be used to change the precedence of operators, which is discussed in the next section.

Description of Boolean Expression Operators

The following table lists the Boolean expression operators in descending order of precedence.

Boolean Expression Operators

Type

Operators

Unary

+, -, !, ~

Multiplicative

*, /, %

Additive

+, -

Relational

< , >, <=, >=, ==, !=

Equality and matching

==, !=, %%, !%

Exclusive OR

^

Logical AND

&&

Logical OR

||


 

The operators classified as the same operator type have equal precedence. The following sections discuss each operator type in detail. As in C, you can override the precedence of operators by using parentheses.

Unary Operators Used in Boolean Expressions

The following unary operators are recognized:

Expressions in which unary operators are used group right-to-left:

+ expression
- expression
~ expression
! expression

The unary plus operator has no effect on the operand; it is recognized and ignored. The result of the unary minus operator is the negative of its operand. The usual arithmetic conversions are performed. Unsigned entities do not exist in FML and thus cause no problems with this operator.

The result of the logical negation operator is 1 if the value of its operand is 0, and 0 if the value of its operand is non-zero. The type of the result is long.

The result of the one's complement operator is the one's complement of its operand. The type of the result is long.

Multiplicative Operators Used in Boolean Expressions

The multiplicative operators—*, /, and %—group left-to-right. The usual arithmetic conversions are performed:

expression * expression
expression
/ expression
expression
% expression

The binary * operator indicates multiplication. The * operator is associative and expressions with several multiplications at the same level may be rearranged by the compiler.

The binary / operator indicates division. When positive integers are divided, truncation is toward 0, but the form of truncation is machine-dependent if either operand is negative.

The binary % operator yields the remainder from the division of the first expression by the second. The usual arithmetic conversions are performed. The operands must not be float or double.

Additive Operators Used in Boolean Expressions

The additive operators + and - group left-to-right. The usual arithmetic conversions are performed:

expression + expression
expression
- expression

The result of the + operator is the sum of the operands. The + operator is associative and expressions with several additions at the same level may be rearranged by the compiler. The operands must not both be strings; if one is a string, it is converted to the arithmetic type of the other.

The result of the - operator is the difference of the operands. The usual arithmetic conversions are performed. The operands must not both be strings; if one is a string, it is converted to the arithmetic type of the other.

Equality and Match Operators Used in Boolean Expressions

These operators group left-to-right:

expression == expression
expression
!= expression
expression
%% expression
expression
!% expression

The == (equal to) and the != (not equal to) operators yield 0 if the specified relation is false and 1 if it is true. The type of the result is long. The usual arithmetic conversions are performed.

The %% operator takes, as its second expression, a regular expression against which it matches its first expression. The second expression (the regular expression) must be a quoted string. The first expression may be an FML field name or a quoted string. This operator yields a 1 if the first expression is fully matched by the second expression (the regular expression). The operator yields a 0 in all other cases.

The !% operator is the not regular expression match operator. It takes exactly the same operands as the %% operator, but yields exactly the opposite results. The relationship between %% and !% is analogous to the relationship between == and !=.

The regular expressions allowed are described on the tpsubscribe(3c) reference page in the BEA Tuxedo C Function Reference.

Relational Operators Used in Boolean Expressions

These operators group left-to-right:

expression < expression
expression
> expression
expression
<= expression
expression
>= expression

The operators < (less than), > (greater than), <= (less than or equal to) and >= (greater than or equal to) all yield 0 if the specified relation is false and 1 if it is true. The type of the result is long. The usual arithmetic conversions are performed.

Exclusive OR Operator Used in Boolean Expressions

The ^ operator groups left-to-right:

expression ^ expression

It returns the bitwise exclusive OR function of the operands. The result is always a long.

Logical AND Operator Used in Boolean Expressions

expression && expression

The && operator groups left-to-right. It returns 1 if both its operands are non-zero; otherwise, it returns 0. The && operator guarantees left-to-right evaluation. However, it is not guaranteed that the second operand is not evaluated if the first operand is 0; this is different from the C language. The operands need not have the same type. The result is always a long.

Logical OR Operator Used in Boolean Expressions

The || operator groups left-to-right:

expression || expression

It returns 1 if either of its operands is non-zero; otherwise, it returns 0. The || operator guarantees left-to-right evaluation. However, it is not guaranteed that the second operand is not evaluated if the first operand is non-zero; this is different from the C language. The operands need not have the same type, and the result is always a long.

Sample Boolean Expressions

The following field table defines the fields used for the sample Boolean expressions:

EMPID    200    carray
SEX 201 char
AGE 202 short
DEPT 203 long
SALARY 204 float
NAME 205 string

Boolean expressions always evaluate to either true or false. The following example is true if both of the following conditions are true:

This example uses a constant integer as a subscript to EMPID. In the following example, the ? subscript is used, instead:

"PETS[?] == 'dog'"

This expression is true if PETS exists and any occurrence of it contains the characters "dog".

 

back to top previous page next page