Expression Editor

It is possible to use dynamic field expressions in place of field name specifications in a form set. You can use these expressions (and Functions) to perform conditional calculations or create conditional labels and filters.

To open the Expression Editor, right click and select Edit Expression from the right-click menu.

Click the Clear button to clear the expression you have entered.
Click the Validate button to check the syntax of the expression you have entered.
Click the Forms button to save the expression, or load a previously saved expression.

For examples of the expressions you can write in the Expression Editor and elsewhere, refer to: Field Expressions.

Field variables, constants, arithmetic operators, comparison and logical operators, and functions, can be included in an expression. The operators used in an expression are evaluated in the following order of precedence:

Constants

Literal constants can be numeric, character, or Boolean.

A number of special constants are also provided:

Constant Description
{ALWAYS} Boolean constant, equates to TRUE.
{BLANK} Equates to NIL but denotes a blank value rather than an undefined value.
{NIL} Equates to NIL and denotes an undefined value.
{Pi} Equates to 3.1415926535897. (π)
{e} Equates to 2.718281828459045. ( == EXP(1) )

Fields

Field name variables are enclosed name square brackets indicate each field name:

=[K2O] > [NA2O]

The square brackets aren’t compulsory but they do make it easier to identify field names in a complex expression. However, they become compulsory if your field names include spaces or reserved characters like ‘+’ or ‘/’.

The ?[<name>] prefix indicates an Output field name attribute. See: Output Field Name Attributes

A [#record] expression variable provides direct access to the record number of the current record. To use every 25th record in a calculation or for labelling:

=if([#record] % 25) = 0 then
    "Label this" 
else 
    "" 
endif		

One potential trap for the unwary is that record IDs start at 1, which means the first record will not be chosen. If this is a problem, just subtract 1 from the record ID:

=if(([#record]-1) % 25) = 0 then
    "Label this" 
else 
    "" 
endif		

Type conversions

Type Numeric String Boolean
Numeric - String containing the numeric value, i.e. “5" for 5 -
String If possible, numeric value from the string. Otherwise NIL. - -
Boolean 1, if TRUE. 0, if FALSE. “1" if TRUE. “0" if FALSE. -

Boolean conversion rules

When writing Boolean {TRUE} or {FALSE} expression results to a file, {TRUE} will be implicitly converted to the number 1 or the character "1", and {FALSE} will be implicitly converted to the number 0 or the character "0", depending on the destination field type.

There is no corresponding implicit conversion from numerical or character values to Boolean when reading from a file, so you must explicitly write the conversion yourself.

Operators

Functions