Variables

Depending on the context in which an expression is to be used, Constants, Field and Attribute variables, Data Source variables and Report variables may be included in the expression.

In the Expression Editor, by default all variables are associated with and grouped by name space. While they are not mandatory, name spaces help prevent naming conflicts and also clarify the context of a given field in an expression.

When you build an expression, if naming conflicts are likely, a variable name may be qualified with a name space using a colon (:) character, as shown below for the Scheduling Core: attribute.

Note that the name space will always be shown in the help box of the Expression editor, as shown below for the Task Attributes:.

All name spaces and variable frames have a language independent ID for use in the expression, and a translated label that the user can read. Both are shown in the variable list and in the help box.

Constants

Literal constants can be numeric, character, or Boolean.

  • 123.4567 – numeric constant;
  • “This is a string" – character constant.
  • FALSE – Boolean constant
  • TRUE – Boolean constant

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 Attributes

Field name variables are enclosed in square brackets which 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 Below.

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		

Wireframe Attributes

Wireframe attribute name variables are enclosed in curly brackets which indicate each attribute name:

=if [Volume] = {Volume} then [...]

The curly brackets are compulsory since they differentiate wireframe attributes from other attributes with the same name, for example a Volume Task attribute as shown above.

Output Field Name Attributes

Output field name attributes can be used in field expressions. For example, the expression below will "high cut" the AU field and output the kriged value to an AU_CUT field. The ?[<name>] prefix indicates an output field name attribute:

=?[AU_CUT] CUTHIGHS([AU], 6.0)

If an attribute has not been specified in an Output field expression, the user will be prompted to specify the name of the Output field:

This is then inserted into the field expression as an Output field name attribute:

Output field name attributes in Chart labels

Default labels in charts often use the input field name to label the data being plotted. If these fields are expressions, then the expressions will be used as the label text:

However, if an Output field name attribute is specified in a field expression, the attribute will be used as the label instead:

Data Source Variables

When you generate a report in the application, it is useful to be able to reference a [Datasource] variable.

A [GeneratorForm] variable allows a Report Generator form set to be used to generate and format a report.

Report Variables

Data Source variables may be combined with function-specific and generic metadata report variables, to generate reports for Scheduling or Resource Optimisation, for example:

Macro Replaceable Pass Parameters

The replaceable pass parameters used in macros can also be used in expressions, for example, to setup a filter or to calculate new field values in the Expression Calculator:

Pass parameters operate on saved form sets. To use them, you must setup the form with the data that is to remain fixed. Pass parameters %1 to %99 can then be entered for the parameters that will change. When you call the form from the macro, the values in the corresponding Par fields (%1 to %99) in the macro record are passed to the function.

Pass parameters can be used to give a partial expression result or a full expression result:

Whenever an expression with replaceable parameters is edited, you can click a Preview button to show what the expression looks like with the macro substitutions applied:

Label Formatting

A New Line character "\n" can be specified in label expressions to allow label text and/or values to be displayed underneath one another: