Any comparison will return 1 as the value of the expression if the comparison is true and 0 if it is not.
The following operators are provided to allow you to compare one value to another value in an expression.
|
Symbol |
Meaning |
|
> |
Greater than |
|
< |
Less than |
|
== |
Equivalent (Notice the double equal sign. A single "=" won't do) |
|
!= |
Not Equivalent |
|
>= |
Greater than or equal |
|
<= |
Less than or equal |
Table 1
An example of a comparison expression is as follows:
Variable("Tank1Level")\value > 50
The preceding is a complete expression. The word “IF” is not required, and indeed is not allowed.
Simply returning 1 if a comparison is true and 0 if it is false is useful (a trigger for alarms is one example), but you can also provide your own values to be returned instead. This is done with an If… Else in four steps, as follows:
1. Put a question mark after the comparison to indicate that you have finished the IF part of the expression
2. Put the value or expression you want returned if the expression is True
3. Put a colon to indicate the beginning of the ELSE part.
4. Put the value or expression that you want returned if the comparison is False.
For example, the following expression will display the words “Within safe limits” while a tank’s level is below 50%, but will display “Above safe limits” when the value rises above 50:
Variable("TankLevel_1")\value <= 50 ?
“within safe limits :
“above safe limits”
You are not restricted to constants for the values that are to be returned. Any valid expression may be used for each of the two cases.
Topics in this section: