InfoConnect API Guide
Attachmate.Reflection.Framework Namespace / Application Class / GetControlsByFilePath Method
The fully qualified file path of the session document file.
Example


In This Topic
    GetControlsByFilePath Method
    In This Topic
    Gets a collection of controls by specifying the session file path.
    Syntax
    'Declaration
     
    
    Public Function GetControlsByFilePath( _
       ByVal filePath As String _
    ) As Object()
    'Usage
     
    
    Dim instance As Application
    Dim filePath As String
    Dim value() As Object
     
    value = instance.GetControlsByFilePath(filePath)
    public object[] GetControlsByFilePath( 
       string filePath
    )

    Parameters

    filePath
    The fully qualified file path of the session document file.

    Return Value

    Array of controls that match the file path.
    Exceptions
    ExceptionDescription
    API Service has not been initialized.
    Remarks
    The method returns a collection of controls that have session file paths that match filePath. The session file path might not be unique among all running sessions.
    Example
    This sample shows how to get controls by the file path name
    //This sample gets the Terminal control of a running session.
    //Before you run this sample, make sure the session used in GetControlsByFilePath()
    //is running in an InfoConnect workspace. If more than one instance of InfoConnect is running,
    //the session must be running in the first instance that was started.
    using System;
    using System.Collections.Generic;
    using System.Text;
    using Attachmate.Reflection.Framework;
    using Attachmate.Reflection.Emulation.IbmHosts;
    namespace ConnectToASession
    {
        class Program
        {
            static void Main(string[] args)
            {
                //Get a handle to an application that represents the first instance of InfoConnect started manually.
                //For production code, use a try catch block here to handle a System Application Exception thrown
                //if the app isn't running.
                Application app = MyReflection.CreateApplication();
    
                //Get the terminal from the session document file path.
                string sessionPath = Environment.GetEnvironmentVariable("USERPROFILE") + @"\Documents\Micro Focus\InfoConnect\demoSession.rd3x";
                object[] terminals = app.GetControlsByFilePath(sessionPath);
    
                //Check to make sure the session is running.
                if (terminals != null && terminals.Length > 0)
                {
                    //Get a screen and then get some text from the screen.
                    IIbmTerminal terminal = (IIbmTerminal)terminals[0];
                    IIbmScreen screen = terminal.Screen;
                    string text = screen.GetText(18, 2, 48);
                    Console.WriteLine(text);
                }
                else
                    Console.WriteLine("No such control exists. Check to make sure that the session from the file is running.");
                
            }
        }
    }
    
    See Also