Reflection Desktop VBA Guide
Key Concepts / Handling Asynchronous Behavior
In This Topic
Handling Asynchronous Behavior
In This Topic

When your macro interacts with a mainframe program, you'll need to handle the asynchronous behavior that occurs between your macro and the host program.

Your macro runs independently of the host program. Two programs are processsing commands (the host program and your macro) and these programs are not synchronized. Because of this asyncronous behaviour, you'll need to pause execution of your macro after you send a command to the host. After the host responds and Reflection processes the data to render a new screen, you can resume execution. If your macro tries to interact with the screen before it is ready, it will get unexpected results or errors.

To handle this asychronous behaviour and make sure your macro waits until the terminal screens or Web pages are ready, use the following Reflection events and methods.

For IBM programs, use the NewScreenReady event to handle asynchronous behaviour.

Using the NewScreenReady Event
Copy Code
Private Sub IbmScreen_NewScreenReady(ByVal sender As Variant)
  
  'Set the Screen ID variables used to identify which screen is active.
  Dim ScreenID1 As String
  Dim ScreenID2 As String
  Dim retVal As ReturnCode
       
  'Get values for the screen IDs every time a screen loads.
  ScreenID1 = Trim(ThisIbmScreen.GetText(1, 2, 3))
  ScreenID2 = Trim(ThisIbmScreen.GetText(1, 1, 5))
 
  'Compare the ScreenID values with known values to determine which screen is active.
  If ScreenID1 = "ATM" Then
     'Send command to host
     ThisIbmScreen.SendControlKey (ControlKeyCode_Transmit)
  ElseIf ScreenID2 = "LOGON" Or ScreenID2 = "Ready" Then
     'Send data to host
     ThisIbmScreen.SendKeys ("ISPF")
     'Send command to host
     ThisIbmScreen.SendControlKey (ControlKeyCode_Transmit)
  End If
   
End Sub


 

 

               

 

 

See Also