Script Edit
  • 06 Feb 2024
  • PDF

Script Edit

  • PDF

Article summary

Use the Script Edit tab to write and debug formulas and expressions, and to create calc tags.

Script Settings

The Script Settings section contains different options depending on whether the Script Type is Expression or Formula.

Script Type: Select Expression or Formula. Expressions are ideal for short, simplistic calculations that will not need to be used repeatedly or require much variability to generalize. Formulas are similar to expressions, but a formula can contain multiple lines of code and can be saved for future reference. Both expressions and formulas can be used to create calc tags.

Expression

Tag Button: Click and drag from this icon to drop the tag with the expression call onto PARCview displays.

Tag with Expression: The full UTag name with the expression modifier. This field builds while the script is edited.

Formula

Tag Button: Click and drag from this icon to drop the tag with the formula call onto PARCview displays.

Tag with Formula: The full UTag name with the formula call and arguments. This field builds while the script is edited.

Formula Type: Select Simple or Advanced. See Simple Formula Reference and Advanced Formula Reference for more information on the differences between simple and advanced formulas.

Formula: The formula name. Select from the drop-down menu or type a new formula name into this field. No spaces allowed, avoid special characters.

Data Type: The data type of the output.

Unspecified: Data type not specified.

Numeric: Output numbers.

Text: Output text values.

Array: Output an array of values. Often used with profile tags.

Digital Text: Output a 1 or 0 along with a corresponding text value.

Description: Verbose description of formula. Spaces allowed.

Formula Owner: Shows the current PARCsecurity identity that has ownership of the formula. Click the button next to the field to open a window where the owner can be changed, if the current user has sufficient permissions (is the owner, has the ownership override role, or is an admin).

Is a Filter: Identifies the script as a filter after it is saved. In trend when the Filter/Formula tag grid context menu option is used, a Filter radio button and a Formula radio button appear in the window. Scripts saved with Is a Filter checked will appear in the drop-down list when Filter radio button is selected. Filters can also be applied to tags and formulas using the /FILTER=FilterName() notation. The named formula, or explicit filter, can take zero or more arguments.

Is Server Safe: The Is Server Safe setting, under certain conditions, allows client side calculations to be run on the server, and have only the results sent back the client (typically client-side calculations are performed by the local HDA server / local in-process server). This can improve the performance of some scripted tags, but should be avoided unless absolutely necessary as it can negatively affect server performance. Requires admin permission.

Script Edit Area

Build the script in the script edit area. See Scripting Reference for more information on building scripts.

The error list provides feedback on any errors during execution.

Output Console

The output console provides verbose details on the execution of the script.

Autos

If using variables within the script, this tab will show the value of the variables during execution.

Calc View

The Calc View displays the records returned by the script.

Time: The timestamp for the output value.

Out Value: The value of the output.

Tag columns: The values of any input tags at the timestamp of the output.

Arguments

The Arguments tab is where arguments are defined. The Name and Type must correspond to the name used in the script and the type expected by script context. If the name is incorrect, the script will not be able to execute because it is missing a required parameter. Entering the wrong data type into the argument will also cause the script to fail.

Name: The name of the argument. This name must match a variable used in the script and all undefined variable in the script must have a name in the arguments tab.

Type: The data type for the argument. Choose between Double (numeric) and String (text).

Value: The value of the argument. This value will only be saved if a calc tag is created from the formula.

Settings

Settings: In the Settings tab, the time span and process area for the calculation can be configured, as well as the behavior of the Calc View tab.

End Time: The latest timestamp the script will pull values for.

Time Span: The length of time in the past from the specified end time the script will search for data.

Now: If this box is checked, the script uses the time the script editor was launched as the end time.

Process: Selects a process area for use with master tags.

Calc View Fill Mode: Whether to wait until execution finishes to fill in the calc view grid or to fill in the grid in real-time.

Status Bar

The status bar appears at the bottom of the Script Editor window during execution and provides the user with feedback.

 


Was this article helpful?