The following are some typical examples of Analyzer expressions, demonstrating the use of most of the operators, parentheses and functions.
For the following examples, assume that for a given record the contents of some of the fields are as follows:
|
Field |
Contents |
Field Types |
|
Salepr |
6 |
Numeric |
|
Name |
ABC |
Character |
|
Cost |
3 |
Numeric |
|
Desc |
de |
Character |
Note: In ASCII, uppercase characters are lower than lowercase characters when compared.
The following table shows various forms of expressions and the results you can expect using the fields described above.
|
Expression |
Result |
|
3+5*6 |
33 |
|
COST+5*SALEPR |
33 |
|
(3+5)*6 |
48 |
|
(3+5)*SALEPR |
48 |
|
COST^COST |
27 |
|
3^COST*4 |
108 |
|
"ABC"+DESCR |
ABCde |
|
NAME+DESCR |
ABCde |
|
SALEPR>10 |
F (False) |
|
SALEPR>3 |
T (True) |
|
NAME>DESCR |
F (see note) |
|
NAME<"LMN" |
T |
|
COST>=3 |
T |
|
COST<=3 |
T |
|
SALEPR>3 AND COST>5 |
F |
|
SALEPR>3 OR COST>5 |
T |
|
SALEPR=6 OR SALEPR=7 |
T |
|
SALEPR=6 AND SALEPR=7 |
F |
|
SUBSTR(Name,1,2) |
AB |
|
SUBSTR("lmnop",COST+1,1) |
o |
|
SUBSTR(NAME,AT(1,"B",NAME),2) |
BC |
As another example, you might create a named expression called Profit, which is the difference between the Salepr and Uncst fields. You can use Profit as part of a filter or logical expression.
To create this named expression and add it to the View, do the following:
| 1. | In the View, right-click and select “Add Columns”. |
| 2. | Click [Expression]. |
| 3. | Double-click Salepr in the Available Fields list. |
| 4. | Click [Minus]. |
| 5. | Double-click Uncst in the Available Fields list. |
| 6. | Enter PROFIT in the Save As text box. |
| 7. | Click [Validate] to check that the expression is valid. |
| 8. | Click [OK] to close the Validate message box. |
| 9. | Click [OK] to close the Expression Builder. |
For more information on creating filters, computed fields (named expressions) and variables, see Filters,Computed Fields and Variables.