Creating a 3270 server script

After you have defined the host application screens and fields used by a 3270 server, use this procedure to create the 3270 server script. In addition to Normal scripts, you may also require Exception Definition and Exception Handler scripts to process exception conditions.

For information about the types of scripts, see About scripts.

If you plan to execute and debug your 3270 server scripts using the Blueworx Voice Response virtual host support described in the Blueworx Voice Response for AIX: Designing and Managing State Table Applications information, there is no live host to determine the current 3270 screen. To ensure that your scripts operate consistently in both real and virtual modes, include the following statements:

CHECK_SCREEN
Whenever a screen is expected, use the CHECK_SCREEN statement to retrieve the screen from the database. In real mode, this statement checks whether the specified screen matches the current screen. In virtual mode, it simulates access to the specified screen.
SET_CURSOR
To set the cursor position, use the SET_CURSOR statement, described in SET_CURSOR. In real mode, the initial cursor position is controlled by the host application. In virtual mode, use SET_CURSOR to explicitly set the initial cursor position on the first screen used by the script.
Note: Because of host delays, which can vary considerably, and because the sequence of screens can vary, you need to build some timing considerations into your scripts, for example, if you are waiting for a screen to arrive (with CheckScreen in a do-while loop). It is important always to have safe exits from these time delays, either with in-line code, or an exception script, to close the host session correctly after failing to receive a correct response. This will help to avoid continuous loops and unnecessary use of processor resources.

For an example, see Using the Statements menu.

To create a 3270 server script:

  1. From the Welcome window, click on Applications —> 3270 Servers
  2. Select the server: Click the 3270 server you want under Servers.
  3. If scripts for the selected 3270 server are not displayed, click View —> Scripts.
  4. Click Object —> New. The system displays the 3270 Script window.
  5. Specify script properties and description: To specify the script type, click Properties, then one of the following:
    • Normal Script (the default) if the script is for main processing.
    • Exception Handler Script if the script is a specialized routine to handle an exception condition.

      An EXCEPTION statement (described in EXCEPTION) in a normal script specifies the names of the scripts that define and handle a particular exception condition. An exception handler is executed when the exception defined by the corresponding exception definition script is detected and overrides the default exception handler for the specified condition.

    • Exception Definition Script if the script defines an exception to be handled by a corresponding exception handler script. This script will test for the exception while the main script is processing. It is used instead of a default or selected built-in exception definition.
  6. Click Properties —> Description. Type a description and click OK.
  7. Add script language statements: Add the script language statements that define the script in one of the following ways:
    • By importing script language statements (in ASCII format) from a file in the AIX file system to Blueworx Voice Response. For instructions, see Importing scripts.
    • By clicking the required script language statements from the Statements menu. For instructions, see Using the Statements menu.
    • By typing the script language statements yourself.

    Inserting a new statement

    To insert a new statement at a selected position, move the cursor to the statement that will precede the added statement. To insert a statement as the first entry in the script, move to the left of the first statement and press Enter to open a new line.

  8. Validate and save the script: Click File —> Validate & Save. If the script syntax is valid, the Validated field displays Yes. An application that includes this script will not execute unless this field displays Yes.
  9. Save the completed script and confirm the name.
  10. Close the 3270 Script window.

    If the script is invalid, the system displays a message, prompting you to cancel the operation or to save the script as is. The 3270 Servers window displays the new script under Scripts.