Synchronize character-mode (VT) terminals
You select various types of synchronization for character-mode (VT) terminals according to:
-
The design of the application that is running in the terminal emulator
-
The specific action to be synchronized
Wait for the cursor to appear at a specific location
The preferred method of synchronization for VT type terminals is cursor synchronization. Cursor synchronization is particularly useful with full-screen or form-type applications, as opposed to scrolling or TTY-type applications.
Cursor synchronization uses the TE_wait_cursor function. When you run an RTE Vuser script, the TE_wait_cursor function instructs a Vuser to suspend script execution until the cursor appears at a specified location on the screen. The appearance of the cursor at the specified location means that the application is ready to accept the next input from the terminal emulator.
The syntax of the TE_wait_cursor function is:
int TE_wait_cursor (int col, int row, int stable, int timeout );
During script execution, the TE_wait_cursor function waits for the cursor to reach the location specified by col , row.
The stable parameter specifies the time (in milliseconds) that the cursor must remain at the specified location. If you record a script using VuGen, stable is set to 100 milliseconds by default. If the client application does not become stable in the time specified by the timeout parameter, the function returns TIMEOUT. If you record a script using VuGen, timeout is set by default to the value of TIMEOUT, which is 90 seconds. You can change the value of both the stable and timeout parameters by directly editing the recorded script.
The following statement waits for the cursor to remain stable for three seconds. If the cursor doesn't stabilize within 10 seconds, the function returns TIMEOUT.
TE_wait_cursor (10, 24, 3000, 10);
For more information on the TE_wait_cursor function, see the Function Reference.
You can instruct VuGen to automatically generate TE_wait_cursor statements, and insert them into a script, while you record the script. The following is an example of a TE_wait_cursor statement that was automatically generated by VuGen:
TE_wait_cursor(7, 20, 100, 90);

Instruct VuGen to automatically generate and insert TE_wait_cursor statements while recording
Select Vuser > Recording Options. The Recording Settings dialog box appears.
Under Generate Automatic Synchronization Commands select the Cursor check box, and then click OK.

Wait for text to appear on the screen
You can use text synchronization to synchronize an RTE Vuser running on a VT terminal emulator. Text synchronization uses the TE_wait_text function. During script execution, the TE_wait_text function suspends script execution and waits for a specific string to appear in the terminal window before continuing with script execution. Text synchronization is useful with those applications in which the cursor does not consistently appear in a predefined area on the screen.
Note: Although text synchronization is designed to be used with character mode (VT) terminals, it can also be used with IBM block-mode terminals. Do not use automatic text synchronization with block-mode terminals.
The syntax of the TE_wait_text function is:
int TE_wait_text (char * pattern, int timeout, int col1, int row1, int col2, int row2,
int * retcol, int * retrow, char * match );
This function waits for text matching pattern to appear within the rectangle defined by col1, row1, col2, row2. Text matching the pattern is returned to match, and the actual row and column position is returned to retcol and retrow. If the pattern does not appear before the timeout expires, the function returns an error code. The pattern can include a regular expression. See the Function Reference for details on using regular expressions. Besides the pattern and timeout parameters, all the other parameters are optional.
If pattern is passed as an empty string, the function waits for timeout if it finds any text at all within the rectangle. If there is no text, it returns immediately.
If the pattern does appear, then the function waits for the emulator to be stable (finish redrawing, and not display any new characters) for the interval defined by the TE_SILENT_SEC and TE_SILENT_MILLI system variables. This, in effect, allows the terminal to become stable and emulates a human user.
If the terminal does not become stable within the interval defined by TE_SILENT_TIMEOUT, script execution continues. The function returns 0 for success, but sets the TE_errno variable to indicate that the terminal was not silent after the text appeared.
To modify or retrieve the value of any of the TE_SILENT system variables, use the TE_getvar and TE_setvar functions. For more information, see the Function Reference.
In the following example, the Vuser types in its name, and then waits for the application to respond.
/* Declare variables for TE_wait_text */ int ret_row; int ret_col; char ret_text [80]; /* Type in user name. */ TE_type ("John"); /* Wait for teller to respond. */ TE_wait_text ("Enter secret code:", 30, 29, 13, 1, 13, =;ret_col, =;ret_row,
ret_text);
You can instruct VuGen to automatically generate TE_wait_text statements, and insert them into a script, while you record the script.

Instruct VuGen to automatically generate and insert TE_wait_text statements while recording
Select Vuser > Recording Options. The Recording Settings dialog box appears.
Under Generate Automatic Synchronization Commands, select the Prompt check box, and then click OK.
The following is an example of a TE_wait_text statement that was automatically generated by VuGen. The function waits up to 20 seconds for the string "keys" to appear anywhere on the screen. Note that VuGen omits all the optional parameters when it generates a TE_wait_text function.
TE_wait_text("keys", 20);

Wait for the terminal to be silent
In instances when neither cursor synchronization nor text synchronization are effective, you can use "silent synchronization" to synchronize the script. With "silent synchronization," the Vuser waits for the terminal emulator to be silent for a specified period of time. The emulator is considered to be silent when it does not receive any input from the server for a specified period of time.
Note: Use silent synchronization only when neither cursor synchronization nor text synchronization are effective.
You use the TE_wait_silent function to instruct a script to wait for the terminal to be silent. You specify the period for which the terminal must be silent. If the terminal is silent for the specified period, then the TE_wait_silent function assumes that the application has stopped printing text to the terminal screen, and that the screen has stabilized.
The syntax of the function is:
int TE_wait_silent (int sec, int milli, int timeout );
The TE_wait_silent function waits for the terminal emulator to be silent for the time specified by sec (seconds) and milli (milliseconds). The emulator is considered silent when it does not receive any input from the server. If the emulator does not become silent (i.e. stop receiving characters) during the time specified by the time timeout variable, then the function returns an error.
For example, the following statement waits for the screen to be stable for three seconds. If after ten seconds, the screen has not become stable, the function returns an error.
TE_wait_silent (3, 0, 10);
For more information, see the Function Reference.
