You can use Reflection methods to navigate through your sessions:
Navigating and Handling Branching in Open Systems Macros
Navigating by Waiting for a Specified Time
Finding and Moving to Screen Locations
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.
Using WaitForStrings4 |
Copy Code
|
---|---|
Function object.WaitForStrings4(ref string[] text, int timeout, ref int stringidx, WaitForOption option) |
Where...
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
Finding strings recorded for WaitForString3 |
Copy Code
|
---|---|
'Wait for a string on the host screen before continuing returnValue = osCurrentScreen.WaitForString3(ESC & "[11;14H", NEVER_TIME_OUT, WaitForOption.WaitForOption_AllowKeystrokes) |
Using the strings in the macro |
Copy Code
|
---|---|
Public Sub DetermineWhatScreenArrived() Rem This sample shows how to define and wait for several strings to determine how the host responded. Dim i As Integer Dim strArray(0 To 2) As String Rem define the strings to wait for based on the values observed in a recorded macro. strArray(0) = "11;14H" 'We arrived at Apply Tax Screen strArray(1) = "[11;15H" 'We arrived at Order Totals Screen strArray(2) = "[6;54H" 'We arrived at Shipments not Allowed to Location Screen Rem Define the Screen and terminal variables. Dim osCurrentScreen As Screen Dim osCurrentTerminal As Terminal Set osCurrentTerminal = ThisFrame.SelectedView.control Set osCurrentScreen = osCurrentTerminal.Screen Rem Send the VT PF1 key to finalize an order. osCurrentScreen.SendControlKey ControlKeyCode_PF1 Dim retval As ReturnCode Dim returnStringIndex As Long For i = 0 To 2 Rem Wait for the strings in the strArray(), with a timeout of 3000 ms, and allow keystrokes to be entered while waiting. retval = osCurrentScreen.WaitForStrings4(strArray(), 3000, returnStringIndex, WaitForOption_AllowKeystrokes) Rem Print the string that was received. If retval = ReturnCode_Success Then Rem WaitForStrings requires a zero-based array parameter, but it returns a 1-based index of strings. Rem Use a Select Case statement with 1-based values to determine the host response. Select Case returnStringIndex Case 1 Debug.Print "We arrived at Apply Tax Screen" Case 2 Debug.Print "We arrived at Order Totals Screen" Case 3 Debug.Print "We arrived at Shipments not Allowed to Location Screen" End Select End If Next i End Sub |
You can navigate through Open Systems screens by waiting for a specified time between commands.
This is useful for navigating Open Systems screens when you don't know the string values returned by the host (required by the WaitForStrings methods). It can also be used to navigate IBM screens.
You can use Reflection Search functions to find locations on the screen that you want to move your cursor to or use as a starting point for a selection.