Expressions and functions

Many event action parameters make use of multi-part expressions when performing various operations. These expressions can be constructed with the Event Action Expression Editor form, which is a versatile tool that provides many options designed to help you build the parameter expressions you require without writing the code.

To help in the construction of event action parameter expressions, the application provides a large number of standard expression functions, which are all available in the Event Action Expression Editor form. When selected, each function provides a sample of the correct syntax and a brief description.

Pre-parser functions

In addition to the standard expression functions listed in the Event Action Expression Editor form, there are two pre-parser functions that you can use to build expressions:

Function Description
TGC Retrieves the value of an event global constant for which the value can contain other grammar elements
TV Retrieves the value of an event variable in which that value can contain other grammar elements

These additional functions can be used to expand an event variable or event global constant textually with no assumptions about the structure or data-type of the contained value. These functions are useful in cases where the expanded value contains other grammar elements that must be further evaluated, for example, to share common expressions, expression elements, or groups of functions.

When an event action begins, the application first evaluates all TV( ) references recursively, until no more references to known variables remain. Next, the application evaluates all TGC( ) references recursively, until no more references to known global constants remain. Finally, the resulting parameters string is passed to the parser to evaluate all other functions and operators contextually using the grammar found in Expression Grammar.

Simple expansions

Consider this parameters string:

CONDITION(TGC(Over1WeekOld)) TGC(OldHandlerPromptParms)

Assume that the system is using this event global constant metadata:

Name Value
Over1WeekOld DATEDIFF(day, BEGINDATE( ), CURDATETIME( )) > 7
OldHandlerPromptParms TO(USERNAME( )) SUBJECT("Old Handler Alert") QUESTION("Do you really want to continue this old Handler?") CHOICES("1,sYes,0,sNo")

The effective parameters passed to the event system parser are:

CONDITION(DATEDIFF(day, BEGINDATE( ), CURDATETIME( )) > 7) TO(USERNAME( )) SUBJECT("Old Handler Alert") QUESTION("Do you really want to continue this old Handler?") CHOICES("1,sYes,0,sNo")

Complex expansions

More complex expansions are possible; for example:

GC(MyVarTV(VarSuffix))

In this example, the value of the current event handler's variable named VarSuffix is retrieved. Then that value is appended to the MyVar to construct an event global constant name, for which the value is then retrieved.

The value of the VarSuffix can be set dynamically by an event action on the handler, or included in different event initial states that are linked from referring handlers. The GC( ) reference itself can be moved to its own global constant and referred to from all actions of the handlers by using TGC( ).

Note: No operator or other syntax is used around the TV( ) reference, because it is evaluated and substituted in-place textually, without regard to data type or context.

Nested expansions

Nested expansions are also possible. For example, consider this parameters string:

TGC(MarkItUp)

Assume that the system is using this event global constant metadata:

Name Value
StdMarkup * 1.1 + 5
MarkItUp CONDITION(V(Price)TGC(StdMarkup) < 100) SETVARVALUES(Price=Price TGC(StdMarkup))

This metadata has the effect of increasing the value of the Price by 10% plus 5, but only if the resulting value is less than 100.