Scenario 1. A Search Function

There are four phases in a typical host system transaction:
  1. Starting the transaction
  2. Waiting for the host system to respond
  3. Analyzing the response to see if it is the expected response
  4. Extracting and using the data from the response

Your programmed operator can use a series of EHLLAPI functions to mimic these actions. After determining the correct starting point for the host system transaction, the programmed operator can call the Search Presentation Space (6) function to determine which keyword messages or prompting messages are on the display screen.

Next, the programmed operator can use the Send Key (3) function to type data into a host system session and enter a host system transaction. Then the programmed operator can:
  • Use the Wait (4) function that waits for the X CLOCK, X [], or X SYSTEM condition to end (or returns a keyboard-locked condition if the terminal has locked up).

    If the keyboard is inhibited, your EHLLAPI program can call the Copy OIA (13) function to get more information about the error condition.

  • Use the Search Presentation Space (6) function to look for an expected keyword to validate that the proper response had been received.
  • Use the Copy Presentation Space to String (8) function (or any of several data access functions) to extract the desired data.

The Search Presentation Space (6) function is critical to simulate another task of the terminal operator. Some host systems do not stay locked in X CLOCK, X [], or X SYSTEM mode until they respond; instead, they quickly unlock the keyboard and allow the operator to stack other requests. In this environment, the terminal operator depends on some other visual prompt to know that the data has returned (perhaps a screen title or label). The Search Presentation Space (6) function allows your EHLLAPI program to search the presentation space while waiting. Also, while waiting for a response, calling the Pause (18) function allows other DOS sessions to share the central processing unit resource. The Pause (18) function has an option that allows your EHLLAPI program to wait for a host system update event to occur.

If no host system event occurs after a reasonable time-out period, your EHLLAPI program could call a customized error message such as:
No Response From Host.  Retry?

In this environment, program revisions become very important considerations, because the programmed operator must be reprogrammed for even minor changes in the display messages.

For example, if a terminal operator expects the message:
Enter Part Number:
as a prompt, he or she will probably be able to respond properly to an application change that produces the message:
Enter Component Number:

However, because the programmed operator is looking for a literal keyword string, subtle changes in message syntax, even as trivial as uppercase versus lowercase, can make the program take a preprogrammed error action.