Interacting with Hosts using VT Emulation
After sending data to a host, using VT or other non-block mode emulation, you must pause execution until you determine when the host has finished with its reply. Use the WaitForString method for this task. As soon as the final string in a host response has arrived, you can continue execution of your macro.
In some situations the host can reply with more than one response. Use the WaitForStrings method to determine which response the host has made and then apply it to decision branches in your macro.
WaitForStrings4() waits for a specified text string (or strings) to be received from the host.
Function object.WaitForStrings4(ref string text, int timeout, ref int stringidx, WaitForOption option)
text is an array that specifies one or more strings for which to wait.
timeout is a wait timeout value (milliseconds). A value of 0 indicates wait indefinitely.
stringidx is a 1-based index indicating which string in the text array satisfied the condition. (For the first value in the array, stringidx = 1)
option specifies the WaitForOption. Multiple options can be combined using the OR operator.
Note The Reflection API includes several WaitForStrings functions with various levels of functionality. For more information, see the Reflection VBA Help.
To set up your macro, first record a macro to find out which strings you need to look for. (The macro recorder records the WaitForString method with the correct parameters for your host application.) Then set up a function that includes an array of these strings, as shown below.
To set up your macro to wait for VT host data
Dim i As Integer
Dim osCurrentScreen As Screen
Rem Use a Select Case statement with 1-based values to determine the host response.
Note: This sample code is intended to illustrate a concept, and it shows only the code that is relevant to that concept. It may not meet the security requirements for a specific environment, and it should not be used exactly as shown. We recommend that you add security and error-handling code to make your projects more secure and robust. Attachmate provides this sample code "AS IS" with no warranties.