Recommended Strategies for Synchronizing Character Mode (VT and HP)
Recommended Strategies for Synchronizing 3270 and 5250 Applications
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>\models
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.
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.
Review other tips for working with character mode host applications.
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.
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.
Tips:
Example:
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.
Event 1 (WaitForCursorEnterPosition Row, Col)
Event 2 (WaitForCursorEnterPosition Row, Col)
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.
Add synchronization if a block mode screen is received in multiple command chains. Your options include:
Entity validation and synchronization based on cursor position are also available.
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.
Notes:
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.
Tips:
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.
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. More information...
Use the Model Debug Messages debug option to review the real-time data sent and received from a host.