Expressions
Many animations and other entities need to be connected to one or more expressions or values.
Where the description of the field contain the Expression entry in place of Item, you can enter the name of a single item or system variable, or constant values (e.g., TRUE, 0, 1, -1, FALSE, etc..) and VBScript expressions (e.g.. SQR (ITEM_1) / ITEM_2 + 3.6 ).
Note: animation can show the result of an expression, but in this case cannot accept inputted data from XView.
Below some examples of valid expressions:
(ITEM_1 ITEM_2 +) ^ 1/3
ITEM_1/1000
Item_5 * (65-ITEM_1)
Item_3 = 1 (returns -1 if the comparison is true; 0 if false)
Important notes
The OR and AND operators are Bitwise operator, not Boolean operators.
The Digital item type can take the values 0 (OFF) and 1 (ON), while the values TRUE and FALSE, respectively, correspond to the numerical values 0 and -1.
In particular, any value other than 0 is considered True, while the value 0 is considered False. Conversely, an expression that evaluates to True (for example, a comparison) does not return 1 but -1 (the value of True in VB Script syntax).
The NOT operator makes a logical negation according to the VB Script logic
Therefore:
|
ITEM_1 OR ITEM_2 |
For Digital items, the expression returns 1 if at least one item has value 1, 0 otherwise, according to the truth table for the binary OR operation. |
|
ITEM_1 AND ITEM_2 |
For Digital items, the expression returns 1 if both items are 1, 0 otherwise, according to the truth table for the AND binary. |
|
TRUE |
Returns -1 |
|
FALSE |
Returns 0 |
|
ITEM_1 = 2 |
Returns -1 (not 1!) If ITEM_2 has a value of 2, 0 otherwise. |
|
NOT (ITEM_1) |
It does not return the inverse binary (0à1; 1à0) the value of the item, but it has instead: NOT (-1) = 0 For analog data, the resulting value is given by the application of the truth table above exposed to each bit of the argument. To obtain the inverse binary, so that the expression evaluates to 0 if the item is 1, and 1 if the item is 0, it is necessary to introduce an expression of the type: ABS (NOT (CBool (ITEM_1)) |
The final result of the expression must be compatible with the data type expected by the function controlled by the expression itself: the table below shows the results consistent with the main features:
|
If the Expression field refers to the Functionality: |
The expression must return a final value of type: |
|
Text (Text Animation) |
Any |
|
Thresholds for colors, text, images |
Numerical |
|
Visibility |
Boolean (TRUE or FALSE) or Numeric (= 0 or ≠ 0) |
|
Enabling |
Boolean (TRUE or FALSE) or Numeric (= 0 or ≠ 0) |
|
Dynamic change of location or size (animations) |
Whole number |
|
Dynamic variation of the rotation angle (animations) |
Numerical |
|
Value and min / max range limits (animations) |
Numerical |
|
Minimum value; maximum value (animations Slider and Spinner) |
Numerical |
|
Value (animation tool, Checkbox)
|
Numerical |
|
Marked (Menu) |
Boolean (TRUE or FALSE) or Numeric (= 0 or ≠ 0) |
|
Expression (General Calculations) |
Numeric item type for Digital and Analog, Text String, Number, Boolean, or for items of type Text |
|
Expression (Actions on event) |
Boolean (TRUE or FALSE) or Numeric (= 0 or ≠ 0) |