Data binding E - Binding to the general expression
The result of the data binding is a value obtained by evaluating general expression. The value can be a number (Integer, Single ..), Boolean or String.
Data binding configurators:
|Control variable||In this field it is possible to define the control variables. The first variable is named v1, the second v2, etc. The variable names are then used in the general expression. |
The data binding is defined for each variable, which is evaluated right before calculaing the general expression.
|Add||Adding new control variable to the end of the list.|
|Insert||Inserting new control variable above the selected variable.|
|Delete||Deleting the selected control variable.|
Macro expression can be used for input (it is evaluated while the window is opening).
In the expression, it is possible to use:
- object Pm
: for example its mathematical and string methods. See the example Example3
- object pMe
represents the graphic item containing this data binding. See the example Example4
Caution: The pMe in this data binding can be used to get any value from any graphic item of this panel. However this should not be used for calling pMe.PmPanel.Methods, because such calling would initialize synchronous communication with the server causing intensive communication load on Web clients.
This data binding is also functional for Web panels
. The evaluation of the data binding does not need to communicate with the Web server (with PROMOTIC application) - the evaluation is done on the client side (i.e. on the Web browser).
Simple expression containing two variables v1 and v2, multiplication, addition, division, subtraction and brackets.
2 * (v1 + 3) / 2 - v2
The expression returns String and contains conditional evaluation (? :). If v1 equals to 1 then the "start" is returned, otherwise "stop" is returned.
v1==1 ? "start" : "stop"
Expression returns the output of the sinus function.
The user method "MyMethod" of the graphic item is called during the calculation.
More complex expression with multiple conditional evaluation (this kind of expression can sometimes replace the T - Binding to calculation based on a table of values
- if v1 equals to 0, then the result is 12
- if v1 equals to 1, then the result is 24
- if v1 equals to 2, then the result is 50
- otherwise the result is 0
v1==0 ? 12 : (v1==1 ? 24 : (v1==2 ? 50 : 0))
Example of linear value conversion
. This expression can replace the LN - Linear function calculation binding
data binding. Let the linear conversion be as follows (the values 80
can be replaced by any other):
- if v1 equals to 80, then the result is 5
- if v1 equals to 90, then the result is 6
(v1-80)*(6-5)/(90-80) + 5
The following conditions can also be added
- if v1 is less or equal 80, then the result is still 5
- if v1 is greater or equal 90, then the result is still 6
v1<=80 ? 5 : (v1>=90 ? 6 : ((v1-80)*(6-5)/(90-80) + 5))