Skip to main content

Screen expression functions

Screen expressions compute a property of a screen object in the browser. You write them on the Advanced tab of the Tag Binding window (see Write an expression).

Signals​

FormMeaning
Tags.get('Plant.Tank.Level')Value of a signal; tags.get and Tag.get work too. The name can be an expression, for example a CONCAT.
Plant.Tank.LevelThe same, written without Tags.get
valueValue of the signal chosen under Tag to bind
#p#A parameter of a symbol (see Symbols)

A part of a signal is read by adding it to the name:

PartValue
.qualityQuality as a number
.raw_valueRaw value before scaling
.timestampTime of the value
.source_timeTime from the device
.unitUnit

For example Tags.get('Pump1.Speed.quality').

Values​

KindWritten as
Number12, 1.5 (not .5, no exponent)
Text'text' or "text"; \' writes a quote
Truth valuetrue, false
Nothingnull

null, false, 0 and the empty text count as false in a condition; everything else counts as true.

Operators​

From the weakest to the strongest:

OrderOperatorsNotes
1OR, ||, |Gives the left value if it is true, else the right value
2XORTrue if exactly one side is true
3AND, &&, &Gives the right value if the left is true, else false
4NOT, !Reverses a condition
5=, ==, !=, <>, <, <=, >, >=Comparison; = compares, it does not assign; === and !== work as == and !=
6+, -+ joins texts when one side is text
7*, /, %Division by zero gives nothing
8- before a valueNegative

Brackets change the order. Names of functions and keywords can be written in capital or small letters.

Condition​

FunctionResult
if(condition, a, b)a when the condition is true, else b; IIF works too

Both a and b are calculated.

Text functions​

FunctionResult
FORMAT(template, values…)Text with the values filled in: %s text, %d whole number, %f decimal (%.1f one decimal), %% a percent sign
CONCAT(a, b, …)The values joined as text; nothing counts as empty text
STR(x)x as text
NUM(x)x as a number
BOOL(x)x as a truth value
LEN(s)Number of characters
UPPER(s), LOWER(s), TRIM(s)Capital letters, small letters, without spaces at both ends
CONTAINS(s, part)True if s contains part
STARTSWITH(s, part), ENDSWITH(s, part)True if s starts or ends with part
REPLACE(s, old, new)s with every old replaced by new
SUBSTR(s, start, end)Characters from start up to, not including, end (counting from 0; end optional)

Number functions​

FunctionResult
ABS(x)Value without sign
FLOOR(x), CEIL(x)Rounded down, rounded up
ROUND(x, decimals)Rounded to decimals places (0 if left out)
MIN(a, b, …), MAX(a, b, …)Smallest, largest
CLAMP(x, min, max)x kept between min and max
SQRT(x)Square root
POW(x, y)x to the power y
MAP(x, inMin, inMax, outMin, outMax)x scaled linearly from the range inMin…inMax to outMin…outMax. The result is not limited to the output range; use CLAMP for that. If inMin equals inMax, the result is outMin
LERP(a, b, t)a + (b - a) × t: a for t = 0, b for t = 1

Bit function​

FunctionResult
BIT(value, n)True if bit n (counting from 0) of the whole part of value is 1

Examples​

ExpressionUse
if(value > 80, '#ef4444', '#22c55e')Red above 80, else green
FORMAT('%.1f %s', value, Tags.get('Tank.Level.unit'))Value with one decimal and its unit
BIT(Tags.get('Pump1.Status'), 3)Bit 3 of a status word
CLAMP(value / 10, 0, 100)A scaled value kept between 0 and 100
CLAMP(MAP(value, 4, 20, 0, 10), 0, 10)A 4–20 mA signal shown as 0–10 bar; 12 mA gives 5

Good to know​

  • An expression that cannot be calculated returns nothing and the property keeps its design value.
  • BOOL('false') is true: only empty text counts as false.