Overview of COBOL Development in Eclipse
When you develop COBOL applications in Eclipse, you use Eclipse features such as a COBOL perspective, as well as background checking of syntax and COBOL launch configurations. Like in other Micro Focus products, you use COBOL-specific projects, familiar functionality for editing and debugging, and comprehensive COBOL Help.
In this Chapter
COBOL Perspective and Projects
The first step in developing COBOL in Eclipse is to create a COBOL
project. COBOL projects in Eclipse are like other Eclipse projects. A COBOL
project is a representation of the source files (with dependencies) and build
commands used to create your application or program. You create a project using
a wizard and the resulting project is displayed in the Navigator view, from
where you can open your source files.
When you create or open a COBOL project, a COBOL perspective is
automatically opened. Perspectives are an Eclipse concept. They present the
views, menus and options relevant to your activity. The COBOL perspective shows
the Navigator, Outline and Console views, among others. The perspective is
customizable, so you can choose your own views.
Editing
The COBOL editor follows the Eclipse style of editors and provides all
the features you need for COBOL editing. For example, the editor provides:
- Background checking - the syntax of the code you type is parsed
continuously to identify errors. The errors are underlined with red squiggly lines and error information is contributed to the Outline and Problem views. You can turn this off in Preferences.
Regardless of background checking, error information is generated during project builds.
- Code templates - a snippet of code for the statement you are typing,
giving an outline of the syntax for you to fill in the blanks.
- Outline view - shows the structure of the program you are editing (when background checking is on).
This is useful for navigating large programs, for example by clicking on a Data Division item, a COBOL section or
a paragraph to go to it in the code. You can also click a data item declaration in the Outline view and this opens the relevant copybook and goes to the relevant line.
- Collapse/expand - hides/shows sections of the program, such as the
File section, Linkage section and so on. You can hover over a collapsed section
to show it expanded. This is also known as folding.
- Preferences - the editor is customizable from Window >
Preferences > Micro Focus COBOL > Editor. You can change the
above features, as well as colors, line numbers, margins and more.
Copybooks are handled slightly differently in Eclipse from in other
Micro Focus products. You cannot expand the COPY statements to display the copybooks inline.
Instead, you open copybooks just like any other files in their own editor
views. Copybooks are automatically compiled
when their parent files are compiled.
Debugging
The first time you debug a program, you need to create a launch
configuration, which defines the program to debug and configures the debugging environment.
When you start debugging, the Debug perspective is displayed, with the
views useful for debugging. The default views include:
- Debug View (top left by default) - gives a dynamic view of all the threads. For each thread, this view
shows the call/perform stack, showing where the current statement was called from or performed from, and where previous calls and performs came from. You can move the execution point, by right-clicking a thread and choosing an option from the menu.
- Variables View - shows the variables that will be changed by the
current statement, showing the before and after values of them. It also shows
and highlights the variables that changed in the last statement executed. You
can configure this view in Preferences, to display values as hexadecimal, for
example.
- Breakpoints View - shows the breakpoints you have set. To set a
breakpoint, you double-click in the code view, in the margin of the statement
on which to break. You can right-click to see the breakpoint properties, from
where you can set actions to take when the breakpoint is hit.
Building, Project Properties and Configurations
The Project Properties hold all the information to build and run your
application. They hold, among other things:
- Default project configuration - defines the compile settings that are
used by default by all projects, such as the default compiler directives.
- Build configurations - defines the build settings such as the types
of target files to build, the target platform and so on. You can create
multiple build configurations, so that you have one for debugging, one for
release to each target platform and so on.
- Copybook paths - defines the search order of copybook locations.
- Run-time configuration - includes options such as the search order
for called programs, memory allocation, how to handle ANSI displays and so on.
- Properties for individual files, such as Compiler directives that override the directives set for the project.
The project information is held in an xml file .cobolProj in your
project directory. You can view this file in a text editor, but we strongly
recommend you don't edit it.
Next ...