Get a View and its Session Using Title Text
This sample program gets both the View object and the embedded Control object for a session by referencing the title text of the View. For a list of methods by which you can identify View objects, see Terminal and View Objects.
To create a view using its title text
- Start Reflection 2011.
- Create a session document, name it test , and connect it to the host.
- In Visual Studio, create a new Console Application project.
- In the New Project dialog box, type Get View and Session in the Name box.
- Select the Create directory for solution box, click Browse to select your API projects folder (for example, C:\MyProjects), and then click OK.
- In Solution Explorer, add the class assemblies. (For instructions, see Create an API Project.)
- Copy the code from one of the following programs:
Get View and Session (IBM)
Get View and Session (OpenSystems)
- In Visual Studio, paste the code to the Program.cs tab, replacing all existing code.
- In the code, find the following line:
- In the quotation marks, type the filename and extension of the session document that you created in step 2 (for example, test.rdox), making sure to match the letter case.
- Build the application (Build > Rebuild Solution) and then run it (Debug > Start Without Debugging).
A Windows console box appears with a line of text extracted from the host screen, and the following text: "The session is connected to: the_host_address" and "Press any key to continue….."
- To terminate the application, press any key.