Custom screen recognition using global variables

ZIETrans Toolkit provides some screen recognition options using global variables, including these functions:
  • Verify that a global variable exists
  • Verify that a global variable does not exist
  • Verify the integer or string value of a global variable
Refer to ZIETrans User's and Administrator's Guide for information about these options. If you want to perform screen recognition that is based on ZIETrans global variables and the options in the Global Variable Logic panel do not meet your requirements, you can add your own logic based on the values or existence of one or more global variables. This approach does not require you to create a Java™ class; instead, it uses the GlobalVariableScreenReco class, which is provided by ZIETrans, and you can specify comparisons to be made as settings on the <customreco> tag. The format is one of the following:
  • <customreco id="com.ibm.hats.common.customlogic.GlobalVariableScreenReco::{variable(name,option,resource, index)}COMPARE{type(name,option,resource, index)}" invertmatch="false" optional="false"/>
  • <customreco id="com.ibm.hats.common.customlogic.GlobalVariableScreenReco:: {variable(name,option,resource, index)}COMPARE{type(value)}" invertmatch="false" optional="false"/>

Braces {} are used to contain each of the two items that are being compared. The first item is a ZIETrans global variable, whose name is specified in name. You can use option to specify that you want to use the variable's value, length, or existence in your comparison. The resource and index settings are optional. Use resource to indicate whether the global variable is local (which is the default) or shared. Use index to indicate which value to use from an indexed global variable.

The second item can be one of the following:
  • Another ZIETrans global variable, with similar options, in which case the first format is used
  • A fixed value, in which case the second format is used
The valid values for the settings are shown in Table 1. For the COMPARE setting, the only valid values for comparing strings are EQUAL and NOTEQUAL.
Table 1. Valid values for settings
Setting Valid values
type
  • variable
  • integer
  • boolean
  • string
COMPARE
  • EQUAL
  • NOTEQUAL
  • GREATERTHAN
  • GREATERTHANOREQUAL
  • LESS THAN
  • LESSTHANOREQUAL
options
  • exists (boolean)
  • value (string/integer/boolean)
  • length (integer)
  • object (object)
resource
  • local
  • shared
index Any positive integer or 0

The following example compares the values of two local global variables:

<customreco id="com.ibm.hats.common.customlogic.GlobalVariableScreenReco::
		{variable(name=gv1,option=value,resource=local)}EQUAL
		{variable(name=gv2,option=value,resource=local)}" 
		invertmatch="false" optional="false"/>

This expression evaluates to true if the values of gv1 and gv2 are the same.

Now consider the length option. For a non-indexed global variable, length is the length of the value of the variable. For an indexed global variable, if you specify an index, length is the length of that index of the global variable; if you do not specify an index, length is the number of indexed entries in the global variable.

<customreco id="com.ibm.hats.common.customlogic.GlobalVariableScreenReco::
		{variable(name=gv1,option=length,resource=shared)}LESSTHANOREQUAL
		{variable(name=gv2,option=length,index=4)}" invertmatch="false" optional="false"/>

This expression compares the length of gv1 to the length of the fourth index of gv2. It evaluates to true if the length of gv1 is less than or equal to the length of the fourth index of gv2. You can use LESSTHANOREQUAL because length returns an integer value.

The use of resource=shared on gv1 in this example indicates that gv1 is a shared global variable. The other option is resource=local, which is the default, and means that the global variable is not shared with other applications.

You do not have to compare one global variable with another. You can compare the length of a global variable with a fixed integer. You can compare the value of a global variable with another string. For example:

<customreco id="com.ibm.hats.common.customlogic.GlobalVariableScreenReco::
		{variable(name=gv1,option=value)}EQUAL{string(value=mystring)}" 
		invertmatch="false" optional="false"/>

This expression compares the value of gv1 with the string that is contained in mystring. The string can be a fixed string, the value of a variable, or a value that is returned from a method call. In general, you do not need to use custom logic to compare the length or value of a global variable to a fixed value; you can add these comparisons using the Global Variable Logic panel.