WaitForHostUpdate
WaitForHostUpdate
Waits for the host to send new screen data. Not useful for VT emulation, which is character based rather than screen based.
Syntax
FlexScreen.WaitForHostUpdate([WaitMSec], [EnableTimeoutError])
Parameters
|
|
[WaitMSec] |
Integer, input, optional |
|
|
|
Number of milliseconds before the wait times out. |
|
|
[EnableTimeoutError] |
Boolean, input, optional |
|
|
|
Determines whether a timeout raises a run-time error. If omitted, the value of FlexScreen.EnableRuntimeError is used (True unless changed). |
Remarks
If the optional WaitMSec parameter is specified, it is the maximum wait time. If it is omitted, FlexScreen.WaitTimeoutMSec is used (20000 unless changed).
WaitForHostUpdate returns True as soon as the host sends new screen data, or False if none arrives within the wait time. If it times out while EnableTimeoutError is True, run-time error &H80131505 is raised: "Function 'WaitForHostUpdate' timed out after n ms." That includes EnableTimeoutError being omitted while EnableRuntimeError is True. Unless the macro handles the error, it stops.
Note that under On Error Resume Next, the assignment is skipped when the error is raised. So a variable such as Ok keeps its previous value instead of becoming False. To test the result, pass False for EnableTimeoutError, or set FlexScreen.EnableRuntimeError to False, and check the return value.
Screen data received after the last AID key, and not yet consumed by an earlier wait, also counts: WaitForHostUpdate then returns True at once.
Example
Sub Main()
Ok = FlexScreen.SendKeys("MyUserID")
Ok = FlexScreen.SendKeys(FlexKey.ENTER)
' wait up to 10 seconds for the host's reply; a timeout is not an error here
Ok = FlexScreen.WaitForHostUpdate(10000, False)
If Not Ok Then MsgBox "No reply from the host."
End Sub