Expressions are plain VB.Net statements, such as arithmetic expressions or calls to script.class
methods from the project, executed according to the Trigger or execution settings. IntelliSense only shows tags and application objects, but the standard VB.Net compiler is the one that compiles expressions. Whatever you write in the code editor should also be accepted in expressions.
On this page:
Besides the table in Script → Expressions, you can use expressions in several other places using the syntax described here to determine a value or configure a condition. The following is a list of recommendations when using expressions:
The platform has two methods for single-line evaluation, they are as follows:
The IIF method, which currently is used only with VB.Net, has three parameters: IIF (A, B, C)
the first being a condition. This method will return B if condition A is true and C if the condition is false. For example:
IIF (tag.A = 1, "True", "False") |
The code above will return the string True
if the value of the tag.A
is 1, or False
if tag.A
has a different value.
In this .NET method, all three parameters are evaluated regardless of the condition. For instance, given the following code:
IIF (tag.A = 1, script.class.client.Func1(), script.class.client.Func2()) |
Both Func1
and Func2
will always be executed. Only the return value will be different based on the value of tag.A
The TIF method should be used when you want to execute only the function according to the value. For example, given the following code:
TIF (tag.A = 1, script.class.client.Func1(), script.class.client.Func2()) |
Only the Func1()
or Func2()
will be executed, according the value of Tag.A.
The TIF method is defined in the class library that is automatically exposed to expressions that are in the toolkit function library.
For more complex calculations, you can call a class that you create on the Classes tab. See Configuring Classes earlier in this chapter.
Go to Scripts → Expressions.
Select an expression, or select the insert row (first blank row) to create a new expression.
Enter or select information, as needed.
Script Expressions Configuration Properties | |
---|---|
Field | Description |
Object | Select an existing tag or object. |
Expression | Enter the expression. The expression can be a basic mathematical expression, a class, or a conditional expression. |
Domain | Select where the expression executes:
|
Execution | Select when the expression executes:
|
Trigger | Enter or select the tag or object that triggers the expression execution. The expression executes when the value of the object changes. |
DisableCondition | Enter or select the tag or object that disables the expression execution. |
Time | Specify the time when the expression runs. |
Label | Set a label to the specified class. |
Build Messages | Return the message status after the expression runs |
BuildStatus | Read-only. Set after you click Verify.
|
BuildErrors | Read-only. Displays any errors encountered during the last build. |
If you need references to your own assemblies, you can use Scripts → References.
As a fully compliant .NET application, you can find free source code to use, including .NET components, products, and libraries. Plus, you can use your own libraries.
In this section...