Dynamically Open a Session

You can open or close sessions dynamically. This example shows how to open a terminal session from another session that is running in the InfoConnect workspace.

Create the Session Document you Want to Open

  1. Open InfoConnect and create the session you want to open.
  2. Save the session in a trusted location. For this example, we saved a session named "gettingStarted" in the Documents/Micro Focus/InfoConnect folder.
You can open only sessions that are saved in trusted locations (Documents/Micro Focus/InfoConnect is a default trusted location). For information about trusted locations and how to add them, see the InfoConnect Help.

Create a Macro to open the Session      

  1. Create or open a new InfoConnect session.
  2. On the Tools tab, select Visual Basic to open the Visual Basic Editor.
  3. In the Visual Basic Project Explorer, right click on the project folder, and choose Insert > Module.
  4. If the session you want to open is not the same terminal type as your existing session, add a reference to the session terminal type. For example, if you are running an Open Systems terminal session and you want to open an IBM terminal session document, you'll need to add a reference to the Attachmate_Reflection_Objects_Emulation_IbmHosts library. To do this, select your project folder in the Project window. Then select Tools > References on the Visual Basic Editor and select the library.
  1. Copy the following code into the module and press F5 to run it.  
    Open a session document from InfoConnect
    Copy Code
    Sub OpenSessionDocument()     ' Objects required to open a new session
        Dim app As Attachmate_Reflection_Objects_Framework.ApplicationObject
        Dim terminal As Attachmate_Reflection_Objects_Emulation_IbmHosts.IbmTerminal
        Dim view As Attachmate_Reflection_Objects.View
     
        Dim sessionPath As String      
     
        'Get a handle to the existing application object (the workspace)
        Set app = GetObject("InfoConnect Workspace")
     
        'Create a terminal control for the new session
        sessionPath = Environ$("USERPROFILE") & "\Documents\Micro Focus\InfoConnect\" & "gettingStarted.rd3x"
        Set terminal = app.CreateControl(sessionPath)
     
        'Create the view used to display the session
        Set view = ThisFrame.CreateView(terminal)
    End Sub
    
    Open a session document from InfoConnect
    Copy Code
    Sub OpenSessionDocument()    
        'Objects required to open a new session
        Dim app As Attachmate_Reflection_Objects_Framework.ApplicationObject
        Dim terminal As Attachmate_Reflection_Objects_Emulation_OpenSystems.Terminal
        Dim view As Attachmate_Reflection_Objects.View
        Dim sessionPath As String
    
        'Get a handle to the existing application object (the workspace)
        Set app = GetObject("InfoConnect Workspace")
       
        'Create a terminal control for the new session
        sessionPath = Environ$("USERPROFILE") & "\Documents\Micro Focus\InfoConnect\" & "gettingStarted.rdox"
        Set terminal = app.CreateControl(sessionPath)
     
        'Create the view used to display the session
        Set view = ThisFrame.CreateView(terminal)
    End Sub
    
                 
    Open a session document
    Copy Code
    Sub OpenALCSessionDocument()
        'Reflection objects required to open a new session
        Dim app As Attachmate_Reflection_Objects_Framework.ApplicationObject
        Dim terminal As Attachmate_Reflection_Objects_Emulation_ALC.AlcTerminal
        Dim View As Attachmate_Reflection_Objects.View
     
        Dim sessionPath As String
     
        'Get a handle to the existing application object (the workspace)
        Set app = GetObject("InfoConnect Workspace")
          
     
        'Create a terminal control for the new session
        sessionPath = Environ$("USERPROFILE") & "\Documents\Micro Focus\InfoConnect\" & "gettingStarted.ialc"
        Set terminal = app.CreateControl(sessionPath)
     
        'Create the view used to display the session
        Set View = ThisFrame.CreateView(terminal)
    End Sub
    
    Open a session document
    Copy Code
    Sub OpenUTSSessionDocument()
        'Reflection objects required to open a new session
        Dim app As Attachmate_Reflection_Objects_Framework.ApplicationObject
        Dim terminal As Attachmate_Reflection_Objects_Emulation_UTS.UtsTerminal
        Dim View As Attachmate_Reflection_Objects.View
     
        Dim sessionPath As String
     
        'Get a handle to the existing application object (the workspace)
        Set app = GetObject("InfoConnect Workspace")
          
     
        'Create a terminal control for the new session
        sessionPath = Environ$("USERPROFILE") & "\Documents\Micro Focus\InfoConnect\" & "gettingStarted.iuts"
        Set terminal = app.CreateControl(sessionPath)
     
        'Create the view used to display the session
        Set View = ThisFrame.CreateView(terminal)
    End Sub
    

Concepts

To open a session, you'll need access to the Application, IbmTerminal (IBM) or Terminal (Open Systems), and View objects:

  • The ApplicationObject is the InfoConnect application.
  • The Frame object is the top-level user interface component for the workspace and it can be used to control the display of the workspace and to create views for the terminal controls running in the workspace.
  • The IbmTerminal (or Terminal) object is the top level control for the new session. The CreateControl method returns the appropriate terminal control for the session document file that you pass to it.
  • The View object represents the user interface aspect of the new session. To display the session, we need to create a View Object for the terminal and we do this using the Frame object.

For more about these objects, see Using the InfoConnect Object Model.

You can also create this macro in a Common project module and then call it to open this session. Macros in the Common project can be called by any session or by workspace actions. For more about this, see Sharing and Referencing Macros and Controlling Macro Execution.

See Also