Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

Overview

Script expressions are statements executed according 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.Its possible call script classes when more code is needed. 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:

Table of Contents
maxLevel3


Configurating Script Expressions

Configuration

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

Evaluation methods

The platform has two methods for single-line

evaluations, the .NET language has the IIF command

evaluation, they are as follows:

  •  The IIF method, which currently is used only with VB.Net

. The IIF command
  • , has three parameters

. Example
  • : IIF (A, B, C)

The
  • the first

parameter is
  • being a condition. This method will return B if condition A is true

,
  • and

it returns
  • C if the condition is false. For example:

    Code Block
    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,

if you have
  • given the following code:

    Code Block
    IIF 
IIF
  • (tag.A = 1, script.class.client.Func1(), script.class.client.Func2())
, both
  • 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
  • TIF method should be used when you want to execute only the function according to the value. For

these scenarios, FactoryStudio has a method called TIF.
  • example, given the following code:

    Code Block
    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

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.|

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.

Build Messages

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. Plus, you can use your own libraries. 


In this section...

Page Tree
root@parent
spacesV10