Interacting with global variables

A global variable contains a value that can be used to pass information from one HATS 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 a Web page and use it elsewhere.

You may share global variables across applications (within the same EAR) during a single HTTP session. Global variables that can be shared between applications are called 'shared variables', where as global variables that are only visible within the scope of a single HATS application are called 'local variables'. Any time you use or create a global variable, you need to specify whether it is a shared or local. The Advanced settings section will allow 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.

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 "HATS", "hats" or Hats" for global variables.

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, list this action before applying a transformation, so that the global variable will appear on the Web page 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 customizations. For information on inserting global variables into transformations and templates, see Insert Global Variable wizard.

Global variables can be used with prompt and extract macros to either 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 JSP. See Incorporating macros for more information about using global variables with macros.

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

To use global variables in business logic, see the HATS 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 event.

Double click on the Project Settings of your HATS project in the HATS Project View. Go to the Events tab and double-click Start or Connect under the Application Events section to open its editor.

 

Home