|Contents:||Main||Chapter||See Also:||Getting Started Manual||Programmer Manual|
Computed expressions can consist of a single element. However, often several elements are joined together using operators. Operators are characters that perform some action on elements.
The simplest operators are the unary operators. They force a numeric interpretation of the element that follows. They can also affect the sign of the resulting number. The unary operators are:
|+||Positive numeric interpretation (sign unchanged)|
|-||Negative numeric interpretation (sign changed)|
Another set of operators takes two elements, manipulates them, and returns a result. These are called binary operators. You can use the following binary operators in computed expressions:
|\||Integer (truncated) division (e.g., 13\2 = 6)|
|_||Concatenation (e.g., "AB"_"CDE" = ABCDE)|
A third set of operators makes a comparison between two elements and returns a true or false value. These are known as Boolean operators. If the outcome of a Boolean operation is true, the value one (1) is returned; if false, zero (0) is returned. You can use these Boolean operators in computed expressions:
|]||Follows (in alphabetical order)|
|[||Contains (e.g., "AB"["A" is true; "A"["AB" is false)|
|!||Or, either element is true [e.g., (2=3)!(5<10) is true]|
|&||And, both elements are true [e.g., (2=3)&(5<10) is false]|
An apostrophe (') means negation or NOT. It can precede any of the Boolean operators. Thus, 6'>8 is read six is not greater than eight, which is true (a one is returned).
In the absence of parentheses, the expression is evaluated strictly left to right. One operator is not given precedence over another. Use parentheses to control the order in which the operations of a computed expression are performed. Expressions within parentheses are evaluated first. Thus 3+4/2 is 3.5, whereas 3+(4/2) is 5.
You can also use parentheses to ensure that the enclosed material is treated as an expression when there might be some ambiguity. For example, suppose you want to force a numeric interpretation of the SSN field. You need to use the + unary operator. However, the following will not yield the desired result:
SORT BY: +SSN
Is the + the unary operator or the sort specifier (meaning that you want to subtotal results by SSN)? In this case, it will be interpreted as the sort specifier. However, if you put the expression in parentheses, the + will definitely be interpreted as an operator:
SORT BY: (+SSN)
An example of a computed expression containing several elements and operators is:
"Beds occupied: "_(NUMBER OF BEDS*OCCUPANCY PERCENTAGE/100)
First, the part within the parentheses is evaluated. NUMBER OF BEDS and OCCUPANCY PERCENTAGE are field names. Their contents are multiplied and the result is divided by 100. That result is concatenated with the literal string "Beds occupied: " giving a result like:
Beds occupied: 484
Reviewed/Updated: March 4, 2007