HowTos > Copy Data Between Terminal Sessions |
This macro copies text from a field on a screen in an InfoConnect demo program to a string variable. Then creates another demo session, navigates to a screen on the new session, and puts the text into a field on that session.
![]() |
This article contains tabbed content that is specific to each terminal type. Be sure the tab for your terminal type is selected. |
Copy text from one session to another |
Copy Code
|
---|---|
Sub CopyDataBetweenSessions() Dim rCode As ReturnCode Dim projectName As String 'InfoConnect objects required to open a new session Dim app As Attachmate_Reflection_Objects_Framework.ApplicationObject Dim view As Attachmate_Reflection_Objects.view Dim screen As Attachmate_Reflection_Objects_Emulation_IbmHosts.IbmScreen Dim terminal As Attachmate_Reflection_Objects_Emulation_IbmHosts.IbmTerminal 'Get the text to copy from the current session projectName = ThisIbmScreen.GetText(1, 39, 5) 'Get a handle to the existing application object (the workspace) Set app = GetObject("InfoConnect Workspace") 'Create a new session and the view used to display the session Set terminal = app.CreateControl2("{09E5A1B4-0BA6-4546-A27D-FE4762B7ACE1}") terminal.HostAddress = "demo:ibm3270.sim" Set view = ThisFrame.CreateView(terminal) 'Wait until Excel is ready While (view Is Nothing) Wait (200) Wend view.Focus 'Get a handle to the Screen object and navigate to the screen we 'want to enter the data on Set screen = terminal.screen rCode = screen.WaitForHostSettle(2000, 1000) rCode = screen.SendControlKey(ControlKeyCode_Transmit) rCode = screen.WaitForHostSettle(2000, 1000) rCode = screen.SendKeys("ISPF") rCode = screen.SendControlKey(ControlKeyCode_Transmit) rCode = screen.WaitForHostSettle(2000, 1000) rCode = screen.SendKeys("2") rCode = screen.SendControlKey(ControlKeyCode_Transmit) rCode = screen.WaitForHostSettle(2000, 1000) 'Put the text into a field in the new session rCode = screen.PutText2(projectName, 5, 18) End Sub |
Copy text from one session to another |
Copy Code
|
---|---|
Sub CopyDataBetweenSessions() Dim rCode As ReturnCode Dim projectName As String 'Objects required to open a new session Dim app As Attachmate_Reflection_Objects_Framework.ApplicationObject Dim view As Attachmate_Reflection_Objects.view Dim screen As Attachmate_Reflection_Objects_Emulation_IbmHosts.IbmScreen Dim terminal As Attachmate_Reflection_Objects_Emulation_IbmHosts.IbmTerminal 'Get the text to copy from the current session projectName = ThisScreen.GetText(2, 28, 3) 'Get a handle to the existing application object (the workspace) Set app = GetObject("InfoConnect Workspace") 'Create a new session and the view used to display the session Set terminal = app.CreateControl2("{09E5A1B4-0BA6-4546-A27D-FE4762B7ACE1}") terminal.HostAddress = "demo:ibm3270.sim" Set view = ThisFrame.CreateView(terminal) view.Focus 'Get a handle to the Screen object and navigate to the screen we 'want to enter the data on Set screen = terminal.screen rCode = screen.WaitForHostSettle(2000, 1000) rCode = screen.SendControlKey(ControlKeyCode_Transmit) rCode = screen.WaitForHostSettle(2000, 1000) rCode = screen.SendKeys("ISPF") rCode = screen.SendControlKey(ControlKeyCode_Transmit) rCode = screen.WaitForHostSettle(2000, 1000) rCode = screen.SendKeys("2") rCode = screen.SendControlKey(ControlKeyCode_Transmit) rCode = screen.WaitForHostSettle(2000, 1000) 'Put the text into a field in the new session rCode = screen.PutText2(projectName, 5, 18) End Sub |
This sample uses the GetText method to get the screen text from the current session.
Then it creates a session as discussed in Dynamically Open a Session.
After creating the new session, it uses the WaitForHostSettle, SendKeys, and SendControlKey methods to navigate through several screens in the new session to the screen with the Project field.
![]() |
For IBM sessions, another approach for this navigation is to handle the NewScreenReady event for the new session as explained in Navigating Sessions. |
Finally, it uses the PutText2 method to put the text into field at the specified row and column for the new session.