Global Functions and Variables

It is possible to specify global functions and variables that will be available to objects in any display. Global functions and variables are defined in Global Definition files that are read by the Display Builder, Display Viewer, Display Server, Data Server and Historian. One instance of each global variable and function exists for each client in all deployments. Depending on how you will be using your function or variable, you may want to define them locally or in an include display file instead.

Use a global function or variable when

        the same function result is needed in most of your displays

        you want the same variable value in all of your displays

 Global functions are updated even if currently open displays do not use those results, therefore avoid defining functions globally unless the results are commonly required information. If you have a function that will only be used in a few displays, you may get better performance using a local or include file function.

Use a local function or variable when

        the function result is only needed in a single display

        the variable is only needed in a single display

Use a function or variable from an include file when

        the function result is needed in only a few displays

        the variable value needs to be different in each display

See “Include Display Files” for more information.

To view global function or variable data, you must create a Global Definition file and then configure Application Options to read that file.

Creating a Global Definition File

A Global definition file is an RTView display (.rtv) file that contains your function and variable definitions. To create a Global Definition file, create a new display (.rtv) file and add your function and variable definitions. Multiple function and variable definitions can be added to a single Global Definition file. You may also create multiple Global Definition files. See “Functions” and “Add/Edit Variables” for more information.

When you have finished adding all of your function and variable definitions and configuring their properties, save this file as your Global Definition (.rtv) file. You are now ready to add this file to the Globals tab of the Application Options dialog.

Creating a Reusable Global Definition File

You can create a reusable Global Definition file by specifying substitution value(s) in your function definitions and in the Application Options dialog. See “Substitutions” for more information.

To give an example, let us say that your production data is broken down by Plant, Units Completed and Units in Production. Instead of manually creating a function to sort each column in your table, you could create a single global function named Sort (in a Global Definition file named SortFunc.rtv) and reuse it as a template for the others.

In the Application Options dialog, select the Globals tab and separately add the following files and corresponding substitutions:

SortFunc.rtv     $fname:completed $sortColumn:'Units Completed'

SortFunc.rtv     $fname:inProd $sortColumn:'Units in Production'

SortFunc.rtv     $fname:plant $sortColumn:Plant

Once SortFunc.rtv is added and applied in the Globals tab, the Sort.$fname function will show up in the Function dialog three times: Sort.completed, Sort.inProd and Sort.plant.

You can also include variables in your Reusable Global Definition file. If the SortFunc.rtv file in the example above had a Public local variable named $fname, the $fname variable would show up in your Variable dialogs three times: $fname.completed, $fname.inProd, and $fname.plant.

Note: In this example we created a function named getSortCol that is intended to be used only as an input to the Sort.$fname function and should not be defined as a global function. When the function getSortCol was created the Public option was not selected, which prevents the function from appearing in the Attach to Function data dialog in any files except the global function definition file.

Adding a Global Definition File to Application Options

In the Display Builder, select Tools>Options>General>“Globals Tab” to specify any number of Global Definition files and, optionally, corresponding substitutions.

Viewing Global Data

See “Attach to Function Data” for information on viewing the results of your global functions and “Attach to Variable Data” for information on viewing global variables.