Macro Script File Structure

Top  Previous  Next

The Macro script file has a JavaScript function that allows the interaction with the emulation screen.

The script is structured in the three main sections:


1. Obtain the Display Object:


The command getDisplay() will return an object display, the resource that will allow interaction with the emulation screen.


2. Define the Macro Steps:


In this section there should be a function for each step to be executed by the macro. A step generally ends with an AID key command sent to the host.


3. Set the Order for the Steps to be Executed:


At last, it is necessary to set the sequence in which all the steps will be executed. The display.addNavigationPath command should be used to complete this section.



Macro Script Example


(function () {


  // Section 1- Obtains the object to interact with the emulation

  var display = getDisplay();



  // Section 2 - Macro execution steps

   step1 = function () {



       display.cursorPos = 295;




   step2 = function () {

       display.cursorPos = 561;




   step3 = function () {

       display.waitForField("R20C7", 5000);


       display.cursorPos = 1534;




   step4 = function () {


       display.setField("R11C3", "4");

       display.cursorPos = 883;




   step5 = function () {

       display.cursorPos = 1;




   step6 = function () {

       display.setField("R21C7", "go main");

       display.cursorPos = 1614;




   step7 = function () {


       display.cursorPos = 1529;





  // Section 3 - Order in which the macro steps will be executed

   display.addNavigationPath(this, null, null, step1);

   display.addNavigationPath(this, step1, null, step2);

   display.addNavigationPath(this, step2, null, step3);

   display.addNavigationPath(this, step3, null, step4);

   display.addNavigationPath(this, step4, null, step5);

   display.addNavigationPath(this, step5, null, step6);

   display.addNavigationPath(this, step6, null, step7);




You can also see more examples, by creating macros from the z/Scope Anywhere interface and then opening the generated script files to see how they were written by the application (here you can find out where they are going to be placed by z/Scope Anywhere).



Read More:

Creating Macros
Macro Methods and Properties