Understanding the Basics of Expressions

There are 2 types of expression in ClearSCADA:

Expressions can contain tags that are used to obtain values from a database. For example, an expression can contain a tag that represents the CurrentState value of a database point.

Expressions can 'call' various built-in functions. For example, you can include the REGISTRY function in an expression to read a value that is stored in the Windows registry. If you needed an expression to calculate the largest value in a list of values, you would include the MAX function in your expression. For more information on the available functions, see Functions.

Example:

The following expression is used to animate the color of a shape on a Mimic so that it changes color according to the value of an analog point:

IIF (".AI1.CurrentValue">=60, RGB(255,0,0), RGB(0,255,0))

Where:

  • IIF is a function that returns one of two values depending on the result of a comparison
  • ".AI1.CurrentValue" is the tag that is used to obtain the current value of a point named 'AI1'. (The 'AI1' point is stored in the same group as the Mimic in this example)
  • >=60 compares the value of the point with the value 60. If the point value is 60 or above, the color of the shape is set to the color defined by the first RGB function. If the point value is below 60, the shape is set to the color defined by the second RGB function
  • RGB(255,0,0) is a function. The expression contains 3 numbers that represent the color values (Red, Green, and Blue) for the color that is returned (in this case, red)
  • RGB(0,255,0) is a function. The expression contains 3 numbers that represent the color values (Red, Green, and Blue) for the color that is returned (in this case, green)
  • ) closes the arguments for the IIF function.
  • So, when the value of the 'AI1' point is below 60, the shape on the Mimic is green; when the value is 60 or above, the shape is red.

Now that you have a basic understanding of the purpose of expressions and know something about their syntax, you can start thinking about creating your own expressions. Before you start your own expressions, you should familiarize yourself with the Grammar for Expressions.

We also recommend that you refer to the following sections:


Disclaimer

ClearSCADA 2017 R3