Overview
Script expressions are statements executed according the Trigger or execution settings.Its possible call script classes when more code is needed.
On this page:
Table of Contents | ||
---|---|---|
|
Script Expressions Configuration
Besides the Script → Expressions table, you can use expressions in several other places by using the syntax described here. This can be done to determine a value or to configure a condition.
Expressions are plain VB.Net expressions, such as arithmetic expressions or calls to script.class methods from the project. IntelliSense only shows tags and application objects, but the expressions are compiled using the standard VB.Net compiler. Whatever you would write in the code editor should be accepted in expressions as well.
Our platform implements automated replacements, such as"==" to "=". The syntax of an expression is close to a C# statement but without a need to add the semicolon “;” at the end.
Therefore, both VB.Net and C# programmers are able to use the expression fields seamlessly.
In expressions, you do not need to put an "@"before tag names. You need the "@" in the code editor to differentiate project tags from .NET variables. However, expressions do not have local .NET variables, so you use the project object directly.
For arithmetic operands, use the standard operands as described in the .NET documentation.
To allow single-line evaluations, the .NET language has the IIF command, which currently is used only with VB.Net. The IIF command has three parameters.
Example: IIF (A, B, C)
The first parameter is a condition. This method will return B if condition A is true, and it returns C if the condition is false.
IIF (tag.A = 1, "True", "False")
will return the string "True
" if the value of 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, if you have 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 oftag.A.
The IF or IIF methods need to evaluate the parameters before calling the method. There are many scenarios where you may want to execute only the function according to the value. For these scenarios, FactoryStudio has a method called TIF.
Use the expression:
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.
Adding or editing Script Expression
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. |
Managing External References
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.
Heading 2
Heading 3
Paragraph
In this section...
Page Tree | ||||
---|---|---|---|---|
|