Skip to main content

Expression syntax of internal signals

An expression signal computes its value from other signals with a formula, for example {T101.Level} * 0.01 * 120. The server evaluates it each time one of its inputs changes. How to create one is described in Internal signals.

Expressions on screens, which animate objects, use a different syntax; this page applies only to expression signals.

Signal references​

FormExampleNote
In braces{Line1.Pump1.Current}Always works, also for path parts that start with a digit, such as {1A.Feeder}
Bare pathLine1.Pump1.CurrentMust start with a letter or _

A path consists of parts of letters, digits and _, separated by dots. A name directly followed by ( is a function, not a signal. An expression cannot refer to its own signal.

Literals​

KindExamples
Number12, 1.5, .5, 1.5e3
Text'AUTO', "AUTO" (no escape characters)
Logicaltrue, false (any capitalisation)

Operators​

From lowest to highest precedence:

PrecedenceOperatorsMeaning
1or, ||Logical or
2and, &&Logical and
3not, !Logical not
4==, !=, <, <=, >, >=Comparison
5+, -Addition, subtraction; + with a text joins the texts
6*, /, %Multiplication, division, remainder
7- (in front)Negative value

not binds less tightly than a comparison: not {A} == 1 means not ({A} == 1). Use parentheses when in doubt.

Functions​

Function names may be written in any capitalisation.

FunctionArgumentsResult
if(c, a, b)exactly 3a if c is true, otherwise b; only the chosen branch is calculated
min(x, …)1 or moreThe smallest value
max(x, …)1 or moreThe largest value
abs(x)1The absolute value
floor(x)1Rounded down
ceil(x)1Rounded up
round(x), round(x, n)1 or 2Rounded to n decimals (0 by default, at most 15)

Type rules​

  • In calculations a logical value counts as 1 or 0, and a text is read as a number. A text that is not a number is an error.
  • Two texts are compared alphabetically; otherwise values are compared as numbers. If a text cannot be read as a number, == is false and != is true.
  • As a condition, a number is true when it is not 0, and a text is true when it is not empty, 0 or false.
  • The result is converted to the data type of the signal. Whole-number types round it; a result outside the range of the type counts as an error.

Missing and bad inputs​

  • If any input has no value or a bad quality, the expression is not calculated. The signal keeps its last good value with a Bad quality, or has no value if it never had one. This applies to all inputs, also to those in the branch of if that is not used.
  • Division or remainder by zero and a result that is not a finite number also count as an error, with the same effect.

Limits​

LimitValue
Length of the expression4096 characters
Different input signals64
Nested parentheses and functions32 levels
Depth of the formula64 levels, for example 63 operators in one chain

Errors​

The configuration editor checks the expression when you validate or apply the configuration. The message names the character position and the problem, for example an unknown function sqrt at character 12.