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.
Note: 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:
  • With a Set global variable or Extract global variable action on a screen event or application event
  • By prompting the user for a value in a screen transformation
  • By prompting the user for a value while running a macro
  • By setting a value in the macro source code
  • By setting the value in a business logic program.
After a global variable has a value, you can use that value in the following ways:
  • To calculate the value of another global variable, in a Set global variable action
  • To write the value to a host screen, using an Insert Data action
  • To insert the value into a transformation or a template, using the Insert Global Variable menu item
  • To pass the value to a macro
  • To use the value in business logic
  • To use as a criterion in screen recognition

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.