Host Integrator Synchronization Techniques


Recommended Strategies for Synchronizing Character Mode (VT and HP)

Recommended Strategies for Synchronizing 3270 and 5250 Applications

Other Options

Debugging Synchronization Problems


Your host application may be unpredictable when slower execution masks missed synchronization issues. Synchronization in a Host Integrator model ensures that the entire host screen has been received before reading or transmitting data. If you don't develop methods to ensure synchronization, the model can read incorrect values from attributes and fields, write to the wrong locations, or fail to position the cursor at a desired location.

Synchronization is important in operations, when writing attributes, and when using cursor movement commands.

Implementing synchronization techniques is critical for any VT or HP character mode model, and can be important for 3270 and 5250 block mode models where the screen is received in multiple command chains. To view a model example of a VT host application, see the Pine model located in your <VHI install directory>\examples\ModelSamples folder.

There are two basic techniques for ensuring synchronization.

Note: These recommendations rely on improvements to operation handling added in version 6.0. If you are working on a model created with an earlier version of Host Integrator, disable the compatibility switch Verastream 5.5 Host Data Processing Compatibility.

Strategies for Synchronizing Character Mode (VT and HP)

Character mode applications require extra effort to ensure that the model is in synch with the host screen.

In general, using an appropriate Wait command to end an operation is the most reliable technique for ensuring synchronization. The wait commands below are listed with the most highly recommended strategies listed first.

WaitForCommString Command and Nonprintable Characters

For VT and HP character mode hosts, you can wait for datastream sequences that include nonprintable characters such as carriage return, linefeed, and the escape key. These sequences can be captured by copying and pasting text from the Model Debug Messages dialog box into the Operation Edit dialog box when the WaitForCommString command is selected. An example of this syntax is "\033EnterData", which represents the escape key followed by the string data. This syntax represents the C programming language conventions that use a backslash (\) followed by three octal numbers to represent any character.

WaitForMultipleEvents Command

Many operations have alternate destinations; the best way to synchronize at a destination is to use the WaitForMultipleEvents command. In the example below, the first event satisfied when reaching a destination, but the second event is satisfied with a second destination.



Create global events in the Event Edit dialog box using host event commands at the end of the operation to verify that the cursor position has returned to a particular location.

  1. Click the right arrow button and select New Host Screen and Cursor Enter Position. Make sure to specify the row and column coordinates.

    The first command waits for the cursor to return to a specific position, and the second command specifies a second cursor position. The following events now appear in the Events box:

    Event 1 (WaitForCursorEnterPosition Row, Col)
    Event 2 (WaitForCursorEnterPosition Row, Col)

  2. Click OK.
  3. Open the Operation Edit dialog box, click the right arrow button, point to Events, and select the WaitForMultipleEvents command.
  4. Under Command parameters, click the Edit button to open the Event Expression Editor dialog box.
  5. Select Event 1, click the And button, and select Event 2.
  6. Click OK.

    The Operation Edit dialog box opens and displays your new WaitForMultipleEvents command in the Commands box.

Writing Data to the Screen

When writing data to the screen, notice the mode of the terminal. If the mode is insert, for example, you may have to issue a special command to clear a field before transmitting the data (see the Pine model for an example). If the mode is overwrite, then you may need to utilize the Erase to end of attribute setting in your attributes. Failing to do so could result in garbled data when a shorter piece of data is written over a longer one, leaving the end of the original data in place to be sent to the host.

If you are working with a character mode host, take special note of the Attribute Echo tab options related to waiting for character echo. Failing to wait for character echo can often cause subsequent operations or cursor movement to fail. The same issues apply to static transmission commands (TransmitANSI, for example) that you can utilize in operations.

Strategies for Synchronizing 3270 and 5250 Applications

Add synchronization if a block mode screen is received in multiple command chains. Your options include:

Other Options

Entity validation and synchronization based on cursor position are also available.

Entity Validation (Validation tab of Advanced Entity Properties)

Configuring entity validation is helpful when modeling character mode applications since there is nothing in the character mode datastream to denote what constitutes a screen. In general, using the Wait options described above is recommended over using to entity validation.

On the Validation tab of the Advanced Entity Properties dialog box, use the arrival validation options to configure how to validate a certain entity. This validation enables Host Integrator to delay its entity arrival notification until certain conditions are met. Select one of the following options to configure entity validation:

Option 1:
Select the Wait for cursor check box to validate the entity once the cursor arrives at a certain position. Specify the position in the Row and Col boxes.

Option 2:
If Option 1 fails, select the Wait for patterns check box and move one or more configured patterns from the Unused list to the Check list. Once a validation pattern is moved to the Check list, Host Integrator will not validate the entity until this pattern is identified.


Option 3: Select the Wait for condition check box to create a condition in the Condition Edit dialog box. This option often handles situations where the final cursor position may be at any of several locations.

Synchronizing for Cursor Movement and Writing Attributes

When you need to synchronize cursor movement for writing attributes, use a post-write operation to position the cursor at the next attribute. The Wait commands described above work for these synchronization tasks as well.

If post-write operations don't cover cursor movement requirements, you may need to define cursor movement command lists for VT and character mode HP hosts. Cursor movement definitions are especially important when the cursor cannot be moved to a location on the screen with the arrow keys. Without a cursor movement command list, Host Integrator's default is to use the arrow keys. For example, if the cursor is at (2,2) and the attribute is at (2,10), Host Integrator sends eight right arrow keys to the host attempting to end up at the correct location. Sometimes, these host applications can be unpredictable and the cursor may not end up in the same position each time that screen is used. If Host Integrator does not reach the expected location, you will receive the error that the cursor could not be moved.


Example using the Tab key with a VT host:

TransmitTerminalKey rcVtTabKey

Example using the Return key with an HP host:

TransmitTerminalKey rcHPReturnKey

In each case, the command sends the tab key or return key to move the cursor. If the host does more than move the cursor to the next location (for example, it updates a status line or redraws other sections of the screen), then you should be using tabstops. Use the Model Debug Messages option to determine if the host is doing more than just moving the cursor.

Note: On HP host applications, the Enter key and the Return key are quite different. On HP host applications, the Enter key refers to the keypad Enter key.

Once you've defined a move forward command list, Host Integrator will repeatedly execute this command list until it arrives at the starting location for the attribute or attributes you are writing to. If the host never positions the cursor at the attribute, you will receive an error that the cursor could not be moved.

Tabstops (Cursor Tab)

If the host sends more than one packet in response to the tab key, define tabstops on any entity that has multiple attributes. When tabstops have been defined on an entity, Host Integrator will wait for the cursor to arrive at a defined tabstop after each execution of a move forward or move backward command list.

If moving through the fields of your host application requires application interaction, you may have to define the tabstops manually. Using other techniques, such as implementing Wait commands in post-write operations, is recommended over the use of tabstops.

You can define tabstops for an entity on the Cursor tab.

Debugging Synchronization Problems

Use the Model Debug Messages debug option to review the real-time data sent and received from a host.

Related Topics
Bullet Modeling tips
Bullet Using the Pine model example