Attachmate Worldwide  |   Contact Us  |   The Attachmate Group
Extend. Manage. Secure. More than 30 years in the business. Over 65,000 customers.

Technical Notes

Reflection for the Web Scripting Samples
Technical Note 2535
Last Reviewed 15-Oct-2013
Applies To
Reflection for the Web 2014 (All Editions)
Reflection for the Web 2011 (All Editions)
Summary

This technical note describes how to record, edit, and create macros. Sample macros are provided to use with Reflection for the Web 2014 or Reflection for the Web 2011.

Macro Recording and Editing

Reflection for the Web includes powerful macro recording and editing features that enable you to automate frequently performed tasks. The recorded macros and the macros you create use JavaScript as the automation language, so if you already know JavaScript, the syntax of Reflection macros will be familiar.

Both administrators and end users (with the appropriate permissions to access the Reflection for the Web profiler) can create macros.

The macros that an administrator creates are delivered to all users when they access the terminal session, whereas the macros created by an end user are private to just that user.

Recording a Macro

To get started with macros, record a host logon macro:

  1. In a terminal session, connect to your host computer, but do not log on yet.
  2. From the Macro menu, select Start Recording.
  3. Log on to the host as you usually do.
  4. Once you are logged on to the host, select Stop Recording from the Macro menu.
  5. In the Save Macro dialog box, enter a name for the macro.
  6. Configure other options (described in the online help), and then click Save.

The macro is saved as follows:

If you record the macro while configuring the session in the Administrative WebStation, the macro will be saved to the Reflection server after you save and exit the session.

If you record the macro while running the session as an end user, the macro is saved locally as soon as you click Save in the Save Macro dialog box.

Editing a Macro

After you create a macro, you can edit it later by following these steps:

  1. From the Macro menu, select the Macros command.
  2. Select the macro you want to edit.
  3. Click Edit.

The macro opens into the Macro Editor window, where you can modify the JavaScript macro source.

From the Macro Editor window, detailed information about Reflection API functions is available in the product Help. (From the Help menu, click Help Topics, or from the Macro Editor toolbar, click the Help button.)

Creating a Macro

In addition to recording or editing macros, you can also write macros:

  1. In a terminal session, from the Macro menu, select Macro Editor. A new untitled macro editing window opens.
  2. Write the JavaScript source of your macro.
  3. Test the macro from the Macro Editor by using the commands in the Run menu. The output panel at the bottom of the Macro Editor window shows the result of your macro script.
  4. Save the macro: from the Macro Editor File menu, click Save. When prompted, give the macro a name.

Sample Macros

Refer to the product help for detailed information about the macro features available in Reflection and a few samples to help you get started.

Additional macro samples that illustrate other JavaScript language and Reflection features are available from the Attachmate Download Library. See Obtaining Sample Macros.

Using the Sample Files

To use the sample macros:

  1. Launch the appropriate type of Reflection for the Web session,
  2. Open a new Macro Editor window from the Macros menu
  3. Copy and paste the sample code into the editor window.

To run a macro from the editor window, choose the Run All command from the Macro Editor's Run menu. You can also save the macro, and then run it from the Macros dialog box, available from the Macro menu.

Notes:

Some samples are designed for specific types of emulation, while others will work with all emulation types.

Samples that require a specific session type will display an alert message if you try to run the macro in an incompatible type of session.

Some sample macros use features that are available only with Java 6 or newer and will not run correctly with earlier versions of the Java Plug-in. Comments at the top of each macro indicate any special requirements.

Obtaining Sample Macros

When you are ready to try some advanced scripting samples--and are comfortable using Java and JavaScript programming--download the following file from Attachmate Downloads: RWeb2011macros.zip. Note: These macros apply to Reflection for the Web 2014, as well as Reflection for the Web 2011.

Here is a brief description of each sample macro:

  • findindisplay.js

Finds a string of text on the terminal display. Java controls are used to present a dialog box that prompts for the text to search for.

  • ibm3270screenreco.js, vtscreenreco.js

Basic macros that show how to use the Reflection screen recognition engine to perform an action when an IBM 3270 or OpenVMS host screen appears. The screen recognition methods illustrated in these macros are the basis for many of the other macros included.

  • ibm3270logon.js

An IBM 3270 logon that uses the Reflection screen recognition engine to automate a logon to a z/VM host.

  • openvmslogon.js

An OpenVMS logon that uses the Reflection screen recognition engine to automate a logon to an OpenVMS host.

  • sshlogon.js

Performs a logon to an SSH host, prompting for the username and password.

  • ibm3270automatedsignon.js

Performs an automated sign-on to an IBM System z (3270) host, storing credentials back to the Reflection server. This sample is intended for administrators to assign as the automated sign-on macro when configuring a session in the Administrative WebStation.

Although this sample will work for end-users, it will not save credentials to the Reflection server, and credential prompts will appear each time.

  • ibm5250automatedsignon.js

Performs an automated sign-on to an IBM i (5250) host, storing credentials back to the Reflection server. This sample is intended for administrators to assign as the automated sign-on macro when configuring a session in the Administrative WebStation.

Although this sample will work for end-users, it will not save credentials to the Reflection server, and credential prompts will appear each time.

  • promptsandalerts.js

Shows the use of various alert and prompt methods in the Reflection for the Web ECL API.

  • boston_u_library_search.js

Shows how to create an ECL screen recognition engine and register screens and notification listeners using JavaScript, in order to navigate a university library catalog (Boston University).

Note: For information about programming with Reflection for the Web, see Technical Note 2570.

Related Technical Notes
2183 Developer Tools for Attachmate Products
2570 Programming with Reflection for the Web

horizontal line

Did this technical note answer your question?

           


Need further help? For technical support, please contact Support.