Overview

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:


Configurating Script Expressions

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:

  • 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, VB.NET and C# programmers can use the expression fields seamlessly.
  • You do not need to put an "@" before tag names in expressions. Instead, insert the "@" in the code editor to differentiate your Tags from .NET variables. However, expressions do not have local .NET variables, so you use the solution object directly.
  • Use the standard operands described in the .NET documentation for arithmetic operands.

Evaluation methods

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.

Adding Script Expressions

  • 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:

  • Client: expression executes on each client system. These are expressions that apply locally (on the user's computer). For example, report generation.
  • Server: expression executes on the server system. These are expressions that apply across the application, that is, globally.


The creation of Expressions on Domain Client is restrict by default, in order to ensure compatibility with Web (HTML5) Clients, which don't execute the expressions configured here.

You can modify that setup on Solution → Settings. 

Execution

Select when the expression executes:

  • OnChange: the expression executes when the value of any tag in the expression changes.

  • TriggerOrTimeInterval: the expression executes when the trigger event occurs or when the interval set in the period elapses.

  • ChangeOrStartup: the expression executes when the value of any tag in the expression changes or at startup.

  • TriggerOrTimeOfDay: The expression executes when a trigger event occurs or on a specific time of day

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.

BuildMessages

Return the message status after the expression runs

BuildStatus

Read-only. Set after you click Verify.

  • Green check mark: expression runs without errors.

  • Red X: expression has errors.

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. You can also use your own libraries. 


In this section...

  • No labels