Interacting with global variables

A global variable contains a value that can be used to pass information from one ZIETrans object to another. For example, you can extract information from several locations on a host screen, perform calculations, and insert the result on the current screen or a future one. You can build up an array of strings from one or more host screens and insert them into a transformation. You can extract a string that a user enters into a field on the GUI and use it elsewhere.

Global variables that are only visible within the scope of a single ZIETrans application are called local global variables. Global variables that are visible to and can be used by all ZIETrans Web applications in the same .ear file, are called shared global variables. Any time you use or create a global variable, you must specify whether it is local or shared. The Advanced settings section allows you to specify sharing. The default setting for all global variables is local.

Two global variables with the same name can coexist if one is local and the other is shared.

For ZIETrans Web applications you can share global variables between applications within the same .ear file during a single HTTP session.

A global variable can contain a numeric value, a string, or an indexed array of strings. If you use a global variable to contain an array of strings, you can specify for any action whether you want to use the entire array, a particular index, or all the values starting at a particular index. All operations on global variables are case-sensitive. Do not use names beginning with ZIETrans, zietrans or Zietrans for global variables.

You can set the value of a global variable in these ways:

After a global variable has a value, you can use that value in the following ways:

If you insert a global variable into a host screen, you must list this action before applying a transformation, to ensure that the global variable will appear on the GUI created from the host screen. It might make sense however to insert a global variable into the host screen after a transformation returns and before the host screen is sent back to the host. See Actions for more information about specifying actions for screen events. For information about inserting global variables into transformations and templates, see Insert Global Variable.

Global variables can be used with prompt and extract macros either to provide a value for a prompt or to store a value extracted from the host screen. Global variables can be used in conjunction with macros to combine multiple host screens in a single GUI. See Macros and host terminal and Combining screens for more information about using global variables with macros.

You can override global variables to pass data from the GUI to the application. Local and shared global variables can be overridden. For more information, see Global variable overrides.

They may also be used for screen recognition. For more information , see Screen Recognition Criteria or Begin Screen.

For information about using global variables in business logic, see the ZIETrans Web Application Programmer's Guide.

If you want to use a global variable to accumulate strings or a numeric value from several screens, you can initialize it by adding a Set global variable action to the start or connect application event.

Double click on the Project Settings of your ZIETrans project in the ZIETrans Projects view. Go to the Events tab.

To set global variables in the connect event, double-click Connect to open the event editor. Then you can add the global variable on the Actions tab. This way, the global variable is linked with the action being performed.

The same can be done for the Start event.

You can remove local and shared global variables using the Remove global variable action on a screen event or application event. For more information, see Remove global variable action.

Renaming global variables

You can rename each instance of a global variable. To get a list of all global variables found in a particular ZIETrans project take the following steps:

  1. Select Window > Show View > ZIETrans Global Variables from the ZIETrans menu bar. The ZIETrans Global Variables view will be placed right below the Palette view.
  2. Click on a project in the ZIETrans Projects view to populate the ZIETrans Global Variables view with all the global variables found in the selected project's macros and events. If you select a different project, the ZIETrans Global Variables view will be updated. The content is refreshed when a macro or event of the selected project is added, deleted, or edited.
  3. You can rename a global variable through the ZIETrans Global Variables view by right clicking the global variable to edit the name. You can also double-click on the macros or events listed under each global variable to open them. When you create or edit the macros or events, the ZIETrans Global Variables view will automatically be updated.
Renaming global variables is only supported for global variables defined in macros and events; therefore, the ZIETrans Global Variables view will only display those global variables. Renaming global variables will not rename the global variables in business logic, transformations or elsewhere in your ZIETrans project.

Differences between global variables and macro variables

In ZIETrans, there are two main types of variables; global variables and macro variables. The differences between them are outlined here.

Global variables

Global variables are variables created in ZIETrans Toolkit and used by ZIETrans projects. Global variables are stored outside of the macro script in the ZIETrans .hma source file. They are maintained and updated by ZIETrans runtime. There are two types of global variables:

A local global variable is one that is created within a ZIETrans project, and is only visible to the project.
A shared global variable is one that is visible to and can be used by all the Web applications in an .ear file.

Whether a global variable is considered local or shared depends on whether the Shared check box in the GUI is selected when the global variable is created, or whether the value of the shared attribute of a set, prompt, or extract tag is specified as yes or no in the ZIETrans .hma source file.

Macro variables

Macro variables are variables created in the Visual Macro Editor or the Advanced Macro Editor. Macro variables are internal to macros. They are not used outside of macros. Macro variables are created, stored, and used by the macro engine, and listed in the macro script. For more information about macro variables, see the chapter, Variables and imported Java™ classes, in the ZIETrans Advanced Macro Guide.

In the source of a ZIETrans macro (.hma) file that uses ZIETrans prompts and extracts for global variables, the prompts and extracts are contained in the source file before the macro script. The macro script syntax is enclosed by the <HAScript> and </HAScript> tags.