The Expression Editor

Expressions are written inside an expression editor.  To open the editor, click on the button with three dots, located to the right of the expression display.

Note: you cannot type or edit an expression directly in the text box. You must open the expression editor.

The expression editor

An expression can be as simple as 1 + 1, or even just “1”.  There is no requirement that an expression actually calculate anything.  Expressions can be as simple or complex as you need, but must always return exactly one value.  An expression that uses a variety of calculations on a multitude of tags is perfectly acceptable, so long as the net result is to find one value. 

For example, the following expression is legal. (Multiple calculations on multiple lines, returning one result.  Counts pump starts.)

Latch(PickValid(Edge(Variable("Pump1")\Value, 1), 0), Watch(0,

        Variable("PumpCounter")\Value))

    ? (Value + 1)

    : PickValid(Variable("PumpCounter")\Value, 0)

 

The next example is not (calculates two separate results). 

1 + 1

2 + 2

If a valid expression has been entered, then when you close the editor you will see the expression displayed, followed by a colon and the calculated result of the expression.   You must click on the expression editor’s OK button in order to see the result of your expression – there is no preview for the calculation.

An expression result

Note: Expressions are always examined by VTS for syntax errors before they are saved.  If the expression doesn't follow the rules, then you will be notified that a problem exists. Incorrect expressions are never saved.