An If expression always returns a Boolean result. Therefore, if you want the If expression to perform a Boolean comparison, do not define a comparison operator and a value. Simply specify the variable to indicate that you want to compare the value of the variable to True or 1. For example, assume doorOpen is a Boolean data item, indicating whether the related door is open or closed. The following rule runs ActionA if the door is open and ActionB if the door is closed:
If DataItem.doorOpen.value
Then ActionA
Else ActionB
As shown in this example, If evaluates to true if the door is open (the value of doorOpen is true) and to false if the door is closed (the value of doorOpen is false).
If you want to test whether the value of a Boolean symbol is false, then you use the NOT (!) operator, as shown in the following example:
Trigger: StateChange
If !State.isentry
In this example, the rule is generated by a StateChange message (a state machine either entered or exited a state). The value of the isentry symbol provides the answer to the question, "Did the state machine enter or leave the state?" To test if the state machine LEFT the state, this example uses the NOT (!) operator.
Important! This use of just the variable in the If expression works with Boolean values only. For analog or integer values, you must use a comparison operator when defining the If expression; for example, <, >, =. For example, to check the current value of a data item:
If DataItem.Temp.value > 100
Then ActionA
Else ActionB