Skip to content

Expression Evaluator#

The system comes with a flexible expression evaluator engine which is used to dynamically calculate values. The expression evaluator is used in different parts of the application, specifically in the following objects:

Warning

This engine is not used in the Expression Evaluator Automation Controller Core Task, which uses a separate but equally powerful engine. Please consult the documentation for that particular engine in Task - Expression Evaluator.

This section describes the syntax of the expression evaluator.

Info

The expression evaluator is not case sensitive.

Operators#

Operator Description Usage Result Type
&& AND logical operator expression && expression Boolean
and AND logical operator expression and expression Boolean
or OR logical operator expression or expression Boolean
|| OR logical operator expression || expression Boolean
not NOT logical operator not expression Boolean
! NOT logical operator !expression Boolean
+ Adds the value of two expressions. If the result of one of the expressions is a string, the result will be a concatenation of the two strings. expression + expression Numeric / String
* Multiplies the value of two expressions expression * expression Numeric
- Subtracts the value of two expressions expression - expression Numeric
/ Divides the value of two expressions expression / expression Numeric
== Tests if the values of two expressions are equal expression == expression Boolean
= Tests if the values of two expressions are equal expression = expression Boolean
< Tests if one expression is less than another expression expression < expression Boolean
> Tests if one expression is greater than another expression expression > expression Boolean
<= Tests if one expression is less than or equal to another expression expression <= expression Boolean
>= Tests if one expression is greater than or equal to another expression expression >= expression Boolean
!= Tests if one expression is different from another expression expression != expression Boolean
<> Tests if one expression is different from another expression expression <> expression Boolean
% Module function that returns the remainder after division expression % expression Numeric
^ Raises one expression to the power of another (power function) expression ^ expression Numeric

Table: Expression evaluator - operators

Functions#

Mathematical#

Function Description Usage Result Type Example
abs Absolute value abs(expression) Numeric abs(-3)=3
log Returns the natural (base e) logarithm of a given number log(expression) Numeric log(e) = 1
log(x,y) Returns the logarithm of a specified number on a given base number log(expression number,expression base) Numeric log(1000,10) = 3
log10 Returns the base 10 logarithm of a given number log10(expression) Numeric log10(100) = 2
exp Return e raised to the power of a given number exp(expression) Numeric exp(1) = e
cos Returns the cosine of a given number cos(expression) Numeric
sin Returns the sine of a given number sin(expression) Numeric
tan Returns the tangent of a given number tan(expression) Numeric
random Returns a random number between a minimum and maximum value random(minValue,maxValue) Numeric

Table: Expression evaluator - mathematical functions

String#

Function Description Usage Result Type Example
& Concatenates two strings expression str1 & expression str2 String
substring Returns a new string that is a substring of another string. The substring begins at the specified given index and extends up to the given length substring(exp string, exp startIndex) or substring(exp string, exp startIndex, exp length) String substring("alfa",1,2) = "lf "
length Returns the length of a String Length(expression) or expression.Length String
lower Converts a String to lower case Lower(expression) String
upper Converts a String to upper case Upper(expression) String
replace Replaces a string within a string Replace(exp string, exp find, exp replace) String
contains Checks if a String contains a substring Contains(exp string, exp substring) String
token Gets a specific token within a string token(exp string, exp separator, exp tokenNumber) String
trim Trims a given string Trim(exp string) String

Table: Expression evaluator - string functions

Flow Control#

Function Description Usage Result Type Example
if Tests a condition, and returns one expression if the condition is true and another one if the condition is false if expression then expression else expression Object
if Tests a condition, and returns one expression if the condition is true and another one if the condition is false if(condition,thenclause,elseclause) Object if(10 * 30; 100; 20) = 20
in Verifies if a value is contained in a list exp value in exp list Boolean 10 in array(1,6,7,10) = true
decode Resolves a value for a list of possibilities decode(exp value, exp test1, exp result1, ..., exp testN, exp resultN, exp default) Object decode("a", "b", 10, "a", 20, 30) = 20

Table: Expression evaluator - flow control functions

Variables and Objects#

Function Description Usage Result Type Example
array Creates an array array(expression 1, ... , expression N) Object[]
arraysize Returns the length of an array or of a string arraysize(expression) Numeric
new Creates a new instance of a business object new Object Name() Object New Material()
$ Gets the value of a variable supplied as an input for the runtime $variableName Object $ xml
$1Param * 3 ⚠
$ Gets the value of a variable supplied as an input for the runtime $[expression] Object $ [$vName] $ ["Material Type"]
. Path navigator expression.(expression) Object $ Material.("Name")
. Path navigator expression.expression Object $ Material.Step.Name

Table: Expression evaluator - variables and objects functions

Warning

When the variable name contains a number or a special character and you want to use an expression, you must reference it like this: $["1Param"] * 3. See the following example:

Screenshot showing a constant value of 1234 in an image.

The variables used in these examples must be supplied as an input to the expression evaluator engine. In this case, no specific Material is being accessed, only the variable passed on to the engine as an input.

Environment#

Function Description Usage Result Type Example
host Gets the current host name host String
domain Gets current user domain name domain String
env Gets the value of a given environment variable env(exp variable name) String
now Gets the current date and time (c# -> DateTime.Now) now DateTime
pid Gets the application Process ID pid Numeric
user Gets the current user name user String

Table: Expression evaluator - environment functions

Constants#

Constant Description Usage Result Type Example
false Returns false false Boolean false
true Returns true true Boolean true
pi Returns the value of the PI constant pi Numeric pi
null Keyword that represents the null value null Null null
e Represents the natural logarithmic base e Float e

Table: Expression evaluator - constants