Build and Test a Program
Complete this task to ensure that you can successfully build a sample program using the Reflection 2008 API. In the sample program provided, the code gets a control object from an existing session (identified by its file path) and displays data from that session in a Windows console box.
To create the test project
- Start Reflection 2008, create a session document, and connect to the host.
- Name and save the session document to a trusted location.
- Open the project you created in "Create an API Project."
- Copy the code from one of the following programs:
Get Started (IBM)
Get Started (OpenSystems)
- In Visual Studio, paste the code to the Program.cs tab, replacing all existing code.
- In the code, change the parameter for reflectionApplication.GetControlsByFilePath to the complete path of your saved session document. Between the quotation marks, type the path exactly as it appears, including the drive letter (for example, C:\), any spaces, and the filename and extension of the session document.
- Build the application (Build > Rebuild Solution) and then run it (Debug > Start Without Debugging).
If the build is successful, a console box opens with the text "Press any key to continue..." The console should also include extracted text from the host screen.
If the console doesn't include extracted text, the row and column of the screen that you specified contained no text. Change the row and column values to indicate an area of the host screen that contains text. In the following example, the row and column values appear as "18" and "2" respectively:
string text = screen.GetText(18, 2, 48);