Object COBOL Tutorials (Windows & OS/2) | Objects and Messages Tutorial (Windows & OS/2) |
The COBOL Class Browser is a tool for developing Object COBOL programs. It provides you with a high-level view of an Object COBOL application, enabling you to see the classes in the application, and the class and object methods implemented. The Class Browser also enables you to start the COBOL Checker and Animator V2 so that you can check and debug your programs.
This tutorial gives you a short tour around the main Browser functions. It is not a comprehensive guide to the Browser. For more information, see the chapter Using Browser in your Object COBOL User Guide, and also the Class Browser on-line reference.
This tutorial consists of the following sessions:
Time to complete: 25 minutes.
You can start the Browser from the Class Browser icon or from the command line. The on-line Class Browser Reference tells you how to create new Windows or OS/2 icons to start the Browser for different projects.
In this tutorial you will start it from an icon in the COBOL Workbench Tutorials group.
>>To start the Class Browser
This starts the on-line Class Browser tutorial.
The Browser window appears, then there is a short delay while the Browser loads the files listed in a project file (inherit.prj). This tutorial uses the same files as used in one of the later tutorials (on Inheritance).
You can now move on to the next session, which describes the Browser's components.
In this session, you will look at the main Browser components. The main window area is divided into four panes. The panes along the top, from left to right are:
Shows the programs loaded into the Browser. The Browser displays the class-id, program-id if there is one; otherwise it displays the file-name.
Shows all the component files of the program selected in the class/program selector.
Displays all the sections or methods of the file selected in the file selector.
Beneath these is the:
Enables you to browse or edit the section of code currently selected in the method/section selector
Follow the steps below:
>>To try the Browser selectors
The file selector now displays the file-names for all the source files used by the Account class program. Some file-names are followed by an ellipsis (...), which means that the Browser has not yet loaded and parsed the file.
The text editing pane displays the code for this method.
You can now move on to the next session, which describes the Browser's different view functions.
In this session you will try some of the Browser functions which present the information in the selector panes in different ways.
>>To try different Browser views
This menu is divided into three groups of items; the top group of items changes the view in the class/program selector, and the two groups below change the display in the method/section selector. The checkmarks next to Nested Programs and File Structure tell you that the method/section selector is currently displaying a list of all the nested programs in account.cbl, in the order in which they appear in the file. Object COBOL uses nested programs for methods, so the nested programs view shows you all the methods for a program.
The methods are now listed in alphabetical order, rather than the order in which they appear in the file. However, the class methods are still listed before the instance methods. The instance methods appear below the "object." entry in the method/section selector.
The method/section selector now displays the divisions and sections in the program, as well as the methods.
The Browser rearranges the contents of the class/program selector into alphabetical order.
There is a pause while the Browser sorts the contents of the class/program selector into an inheritance hierarchy (this is the default view). Each program appears below its superclass, with different levels of indent indicating how far a class is down the hierarchy. If you scroll to the top of the class/program selector, you can see that Base is at the top of the hierarchy. Account, an immediate subclass of Base, is indented one space in. SavingsAccount is a subclass of Account and is indented a further space.
You can now move on to the next session, which describes how you can create a new program.
In this session you will use the Browser to create a new program file for an Object COBOL class.
>>To create a new program
This displays the Create File dialog box. Type tutor1.cbl into the File field and push the default button (this is labelled OK, Create or Open depending on your operating system).
program-id
.
The method/section selector displays a set of divisions and sections for a COBOL program. When you tell the Browser to create a new program or class, the Browser creates a skeleton from a template file. The templates for programs and Object COBOL classes are different, and you can customize them (see your on-line COBOL Browser Reference for details).
You can now move on to the next session, which shows you how you can edit the program you have created.
In this session you will use the text editing pane to enter a short program.
>>To edit a program
working-storage section
from the
method/section selector. Click the mouse cursor directly below the
"w" of working-storage section in the text editing pane to put the
text cursor there.
01 aVariable PIC 94) comp-5.
display "I am a test program." .
You can now move on to the next session, which shows you how to compile a program.
In this session you will compile tutor1.cbl, and correct the error in it.
>>To compile a program
There is a pause while the Browser starts a background session and runs the Checker. Then the entries in the method/section selector are replaced by a single line:
* 230-s PICTURE string has illegal precedence or illegal character
(on some displays you will have to select the message and scroll it horizontally with the right cursor key to see the whole message).
In the other two selectors, Tutor1 entries are marked with a hash (#). These indicate that the Checker has found syntax errors, and their general location.
The method/section selector now displays only those sections which contain syntax errors, and displays the error message rather than the section name. In this case it displays the message:
* 230-s PICTURE string has illegal precedence or illegal character
The text editing pane displays the incorrect code, with the offending line highlighted to indicate the error.
01 aVariable...
.
After a pause, the Browser switches back to the File Structure view, indicating that the program has no syntax errors.
If the method/section selector selector appears to have no entries, it is because you left it scrolled too far to the right when you read the error message (in step 1 above). Click on the selector and press the <left-arrow> key until you can see the entries in the pane.
You can now move on to the next session, which shows you how to animate the program you have just compiled.
In this session, you will animate Tutor1.
>>To animate Tutor1
You are prompted by a dialog box to save changes. This is because you have added an extra program to the project.
This starts Animator V2.
While Animator V2 is active, Browser editing functions are disabled. This is because the Browser unlocks all the files loaded into it. There is a brief pause, while Animator V2 starts up. You can now animate the program.
For full information on Animator V2, use its on-line help. Select General Help or Help Index from the Animator Help menu. You can also read about Animator V2 in your Workbench User Guide.
Browser editing is reenabled.
You can now move on to the next session, which shows you how to use the Browser to find where different methods are implemented, and the interface for using them.
The Browser has a function to help you find the implementation of methods. In this session you will use the Browser function to find implementations of some of the methods of the Account classes.
The Browser opens a new window, Method Signatures. In the left-hand pane of the window is a list of all the methods defined in the programs loaded into the Browser.
A template invoke statement for using the "getType" method appears in the right hand-pane. You can copy this to your source code and edit it.
main section
from the method/section selector.
display
statement.
The code is pasted into your program. You can now edit it to turn it into an executable statement.
You can now move on to the next session, which shows you how to exit from the Browser.
If you lose the Method Signatures window behind other windows, you can reselect it from the Help menu or find it on the Windows or PM Task List (press Ctrl+Esc to display the Task List).
In this session you will close the Browser.
Do you wish to save changes?
This concludes the Class Browser tutorial. An OO Object COBOL application consists of many short pieces of code representing methods and the Class Browser enables you to move rapidly between them much more quickly and easily than you could with a conventional editor.
In this tutorial you also learned how to use the Browser to navigate the classes and methods of a project, and how to use the Browser for the different parts of the edit/check/animate cycle.
Copyright © 1999 MERANT International Limited. All rights reserved.
This document and the proprietary marks and names
used herein are protected by international law.
Object COBOL Tutorials (Windows & OS/2) | Objects and Messages Tutorial (Windows & OS/2) |