Wait() action

From The x3270 Wiki

The Wait() action pauses a script until a specified condition has been met.

Parameters

The overall format of Wait() parameters is:

[timeout-seconds,]condition
timeout-seconds
The amount of time to wait, in seconds. The value can include a decimal fraction.
condition
The condition to wait for.

Conditions

3270mode
Wait until the emulator is in 3270 mode.
cursorAt, row, column
Wait until the host moves the cursor to the specified 1-origin row and column. New in 4.2
cursorAt, offset
Wait until the host moves the cursor to the specified offset. New in 4.2
disconnect
Wait until the host session disconnects.
inputField
Wait until the host creates at least one modifiable field on the screen.
inputFieldAt, row, column
Wait until the host creates an input field at the specified 1-origin row and column. New in 4.2
inputFieldAt, offset
Wait until the host creates an input field at the specified offset. New in 4.2
nvtmode
Wait until the emulator is in NVT mode.
output
Wait until the host modifies the screen. See Output synchronization, below, for details.
seconds
Wait for the specified timeout.
stringAt, row, column, string
Wait until the host writes the specified string at the specified 1-origin row and column. New in 4.2
stringAt, offset, string
Wait until the host writes the specified string at the specified offset. New in 4.2
unlock
Wait until the host unlocks the keyboard.

Output synchronization

The Wait(output) action synchronizes with the screen-reading actions. The full definition of Wait(output) is to wait for the host to modify the screen since the last invocation of a screen-reading action. This can be used by a script to minimize the need to poll the screen for changes. For example, if the host periodically updates the screen with new information, the script can just call Wait(output), then use a screen-reading action to get the new data.

Note that if the host disconnects while Wait(output) is pending, Wait(output) will return, but it will not fail. This gives a script a chance to call a screen-reading action to read whatever might have changed on the screen while the host was disconnecting. A subsequent call to Wait(output) will fail, because there is no host session and no pending data. This makes looping through host output very simple. Here is a pseudo-code example that is guaranteed to capture all of the host data and exit when the session disconnects:

while (Wait(output)) {
  Ascii()
}

Examples

Wait for half a second.

Wait(0.5,seconds)

Wait for the host to update the screen, or for 10 seconds to elapse.

Wait(10,output)

Wait for the emulator to enter 3270 mode.

Wait(3270mode)

Wait 3 seconds for the host to create an input field at row 20, column 5. New in 4.2

Wait(5,inputFieldAt,20,5)