Top | Previous | Next |
Expression Language Overview |
The expression language is used to define dynamic values for component properties and expression tags. Expressions often involve one or more other values that are used to calculate a final value. Expressions don't do anything, other than return a value.
The classic example for an expression is to change a temperature that is stored in Celsius to Fahrenheit in order to display it. Suppose you had a tag, Tank6/Temp that was in Celsius. If you wanted to display that tag in Fahrenheit on a Label, you would use an Expression Binding on the label's text property using the following expression:
1.8 * {Tank6/Temp} + 32
Every time that the temperature tag changes, the expression will re-calculate the value and push it into the Label's text property. Now lets say that you wanted to append a "°F" to the end of the label so that the user knew the units of the temperature. You could simply use some string concatenation in your expression, like this:
(1.8 * {Tank6/Temp} + 32) + " °F"
Lets suppose that you wanted to give the user an option to display the value in Celsius or Fahrenheit, based on checking a checkbox. You could add a Check Box component to th screen called DisplayFahrenheit. Then you could use this expression to dynamically display either unit, based upon the user's selection:
if({Root Container.DisplayFahrenheit.selected}, (1.8 * {Tank6/Temp} + 32) + " °F", {Tankf/Temp} + " °C")
Where are Expressions Used? Expressions are used in two major areas:
|