InfoConnect API Guide
Attachmate.Reflection.Framework Namespace / Application Class / GetControlsByName Method
The name of the control. To get all unnamed controls, enter an empty string.
Example


In This Topic
    GetControlsByName Method (Application)
    In This Topic
    Gets all of the controls running on this instance of InfoConnect that match the specified name.
    Syntax
    'Declaration
     
    
    Public Function GetControlsByName( _
       ByVal name As String _
    ) As Object()
    'Usage
     
    
    Dim instance As Application
    Dim name As String
    Dim value() As Object
     
    value = instance.GetControlsByName(name)
    public object[] GetControlsByName( 
       string name
    )

    Parameters

    name
    The name of the control. To get all unnamed controls, enter an empty string.

    Return Value

    An array of controls that match the specified name. If an empty string is passed as the name, an array of unnamed controls is returned.
    Exceptions
    ExceptionDescription
    The API service does not intialize successfuly.
    Remarks
    This method returns a collection of controls that have names that match.

    Initially, the name of a control is an empty string. It can be changed to any text string for future control identification. The name might not be unique among all running sessions and is not saved in its session configuration file when the control is closed.

    Example
    This sample shows how to get all of the unnamed controls running in an application instance.
    //This sample gets all of the unnamed terminal controls running in an instance of InfoConnect.
    //Before you run this sample, make sure at least one session 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;
    using Attachmate.Reflection.Emulation.OpenSystems;
    
    namespace ConnectToASession
    {
        class Program
        {
            static void Main(string[] args)
            {
                //Get a handle to the first Application instance 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.ActiveApplication;
    
                //Get all of the terminal controls that are not named
                object[] terminals = app.GetControlsByName("");
    
                //Check to make sure at least one session is running.
                if (terminals != null && terminals.Length > 0)
                {
                    
                    //Find terminals based on terminal type and host address
                    foreach (Object terminal in terminals)
                    {
    
                        if (terminal.ToString().Contains("Ibm")) 
                        {
                            IIbmTerminal terminalIBM = (IIbmTerminal)terminal;
    
                            //Find specific terminals based on host address
                            //Then get connection status, get text from the screen, or perform other tasks
                            Console.WriteLine(terminalIBM.HostAddress);
    
    
                        }
    
                        if (terminal.ToString().Contains("OpenSystems"))
                        {
                            ITerminal terminalOS = (ITerminal)terminal;
    
                            IConnectionSettingsTelnet conn = terminalOS.ConnectionSettings as IConnectionSettingsTelnet;
    
                            if (conn != null)
                            {
                                Console.WriteLine(((terminalOS.ConnectionSettings as IConnectionSettingsTelnet).HostAddress));
                            }
                          
                        }
                    
                    }
    
                }
                Console.ReadLine();
    
            }
        }
    }
    
    
    See Also