Terminal Emulation & Transformation Community
  • Home
  • Blogs
  • FORUM
  • About
  • Contact
  • Resources

Advanced Macros in HATS – Using Variables and Arithmetic Expression

3/12/2018

0 Comments

 
Picture
As a developer using IBM Host Access Transformation Services (HATS), you can add macros into the HATS application which helps performing repetitive tasks faster and more efficiently. Macros are also the basis for creating RESTful services in HATS.
​

A macro is an XML script that defines a set of screens. Each screen includes a description of the screen, the actions to perform on that screen, and the screen or screens that can be presented after the actions are performed.

Macros can be used to perform the following functions:
  • As an action such as the play macro action or the perform macro transaction action.
  • To connect or disconnect to a host connection.
  • To generate an Integration Object.
  • In transformation of host applications.
You can find more information about HATS Basic Macros in online documentation for HATS

Advanced macros – Use variables and arithmetic expression in macro

​When a macro is recorded using the host terminal, it is stored in the basic macro format. If a macro is edited and support for variables and arithmetic expressions is added, HATS automatically switches the macro to the advanced macro format.

The sections below demonstrate the following steps to showcase the use of Advanced Macro
  • Convert Basic Macro to Advanced Macro format
  • Creating variables
  • Setting up Arithmetic and Conditional expressions

Convert Basic Macro format to Advanced Macro format


A.  To use the basic HATS Macro Editor, right-click the macro name and select Open With > Macro Editor.
Picture
B.   On the Overview page of the basic HATS Macro Editor, click “Advanced Editor”.
 
C.   Select the “Use Variables and Arithmetic Expressions in Macro” check box on the Macro tab
Picture
This enables all the advanced features for your macro. It automatically converts, all input fields where conversion is required, all the strings in your macro and all occurrences of the two special characters’ single quote (') and backslash (\) from their basic representations to their advanced representations.
Creating variables

A.   For creating a new variable click on “Variables” tab and choose “<new variable>” option              from the Variables list box
Picture
B.    Type a variable name in the Name input field. You must enclose the variable name in dollar         signs ($).
Picture
Variable Name Rules:
  • Variable name can contain only alphanumeric characters (a-z, A-Z, 0-9), underscore (_), or hyphen (-).
  • Case is significant (for example, varArgs and varargs are two different names).
  • A variable name cannot be the same as the short name or the fully qualified class name of an imported type.
Type: Select data type from Type list box. Macro object support standard data types: Boolean, Integer, Doubles, Strings and Field types
     C.     Click on ‘Save and Exit’

​After creating variables, below code fragment gets added in the source automatically (Click on Source Tab of macro to view this)

    
Setting up Arithmetic Expression
Some characters that are ordinary characters in the basic macro format are used as operators in the advanced macro format.

e.g. the plus sign (+) and the greater than sign (>).
In basic macro value="'90' + '[enter]'" is considered as normal string whereas in Advanced macro it is considered to be 90 then enter, which implies that the plus sign (+) works as String concatenation operator. When using the basic macro format, the following character or character sequences are not treated as operators:  +, -, *, /, %, ==, !=, >, =, <=, &&, ||, !.

Whereas in the advanced macro format, the following character or character sequences are treated as operators:
  • String concatenation operators: +
  • Arithmetic operators: +, -, *, /, %
  • Conditional operators: ==, !=, >, <, >=, <=
  • Logical operators: &&, ||, !
 
Conditional Expressions (<if> element and <else> element)

​Conditional expressions are useful for developers when they need to add a condition in a recorded macro. In the example below, we use the extract action to capture data from the host terminal and store the data into a macro variable. From the host terminal captured data is 90, which is then stored in a macro variable Mac_Var1
Picture
We use this Mac_Var1 for conditional expression as in the below code snippet.
​

    
As you can see in the above example, the conditional expression uses logical operators and arithmetic expression
  • If condition is TRUE ($Mac_Var$ == 90), the code fragment writes the message Inside If Block on the host screen.
  • If condition is FALSE, the code fragment writes the message Inside Else Block on the host screen.
 
You can find more information about HATS Advanced Macros in the online documentation for HATS.
Ashish Rajpoot
Member Technical Staff
rajpoota@hcl.com
0 Comments



Leave a Reply.

    Archives

    May 2020
    October 2019
    July 2019
    June 2019
    May 2019
    March 2019
    November 2018
    October 2018
    September 2018
    August 2018
    July 2018
    June 2018
    May 2018
    April 2018
    March 2018
    February 2018
    January 2018
    December 2017
    October 2017
    September 2017

    Categories

    All
    HACP
    HACPEE
    HATS
    HOD
    PCOMM

    RSS Feed

Proudly powered by Weebly
  • Home
  • Blogs
  • FORUM
  • About
  • Contact
  • Resources