Chapter 6: Editing Programs

The Integrated Development Environment includes full editing capabilities, enabling you to edit your COBOL and Assembler source code (as well as other flat text files). These capabilities include the usual text editing features, such as text entry, cut and paste and others that make working with programs easier.

Follow these links for more information:

Using Insert and Overtype Mode

You can select whether to edit in insert mode or in overtype mode by pressing the Insert key on your keyboard.

To help you identify when you have changed mode, you can select whether to use a block-style cursor in overtype mode. You set the cursor to block style by clicking Options, selecting Edit, and then checking the Use a block style cursor when in overwrite mode box on the Source Views tab. When you subsequently select a mode, the cursor changes:

Mode Cursor
Insert Vertical bar
Overtype Block

Selecting Columns and Lines

You can select text by dragging the mouse across the source. Dragging can:

Note: Even with column selection enabled, you can select whole lines by dragging in the prefix area of the lines you want. You must drag in the prefix area to select whole lines.

If you drag across out of the prefix area into the text area, you select only a rectangle of text. Although this rectangle may include all the text you want, it does not include the whole lines. If you then cut this rectangle, the text is cut but the empty lines remain intact. When you paste the rectangle, it pushes the existing text to the right. It does not push the existing text down onto subsequent lines.

Selection and Insert or Overtype Mode

The Insert or Overtype mode does not affect column selection and line selection behavior. The normal behavior inserts the pasted text. However, you can overtype existing text by selecting the text you want to overtype and then pasting the new text on top of it.

Printing Selected Lines and Columns

You can print a block of lines or columns you have selected. You do this using the Print dialog. Click File > Print, then from the Print dialog click Selection in the Print Range group. Click OK to start printing the selection.

Undoing and Redoing Edits

Every editing change that you make is added to the undo stack. The undo operation takes the most recently performed operation from the undo stack and unexecutes it. For example, if you deleted a line, the undo operation inserts it again.

You can also undo undo operations, known as redoing. This is useful when you undo more edits than you intended.

Working with Copybooks

Copybooks are an integral part of most COBOL and Assembler programs. Using Mainframe Express, you can select which copybooks you want the editor to display.

Note: There is an option Hide All Copybooks on the View menu which you may want to use if you do not need the automatic display of copybooks. If you use this option, the editor displays a particular file contents only when instructed by debugging or browsing operations. If this option is turned off, the source copybooks are automatically opened and displayed.

A copybook in a program can be in one of three states: shown, hidden or closed.

Showing Copybooks

The editor displays the entire copybook beneath its COPY statement.

When you request Copybook > Show on the File menu, the editor first checks to see if it has information (from the compiler) about the existence of a copy statement at the cursor position. If it does, and that copybook has not already been loaded, the editor opens and displays the file. If the copybook has already been loaded but is just hidden, the editor redisplays the file.

If the program has not been compiled or there is no record of a copybook at that location in the compiler information, the the editor parses the line looking for various copy verbs (depending on the language). If it finds one, it extracts the filename then opens and displays the file.

There is an editor option Lock source files when opening them (Edit > General on the Options menu) which can be on or off:

Note: When loading large files in the source editor, fewer resources are used if you select Lock source files when opening them.

Hiding Copybooks

When you select Copybook > Hide on the File menu, the copybook disappears from the screen. All that is visible of a hidden copybook is its COPY statement. Hide performs different functions, depending on whether or not your program has been compiled:

Closing Copybooks

Close performs the following operations:

Editing COPY Statements

If there is an expanded copybook in the file you are editing, you cannot edit any COPY statements until the expanded copybook has been closed (not just hidden). Trying to edit a COPY statement when a copybook is open results in a message box being displayed. The message box informs you that the COPY statement is locked because of the expanded copybook, and gives you the option of closing the expanded copybook and unlocking the COPY statement to enable you to edit it (Yes) or leaving the copybook expanded and the COPY statement locked (No).

Editing with Bookmarks

Bookmarks are a way of enabling you to mark a line in a file so that you can return to it at a later time. Setting a bookmark on a line displays a book icon in that line's prefix area. You can then:

There are two kinds of bookmarks. A non-persistent bookmark lasts only for the duration of the edit session. A persistent bookmark lasts until you delete it, remaining even if you close and reopen Mainframe Express. You give persistent bookmarks names, and can jump to them by name.

Compressing and Expanding Source Code

When developing a source program, there are a number of operations that put marks in the prefix area. For example:

If you cannot see these marks, the prefix area may be hidden. To make it visible, right-click in the editing window and click Prefix Area on the popup menu.

As well as moving to the next and previous marked line with a single click, you can also compress the code to show only the marked lines, by clicking .

Compressing a file hides the unmarked code, so that only the marked lines are displayed. If there is more than one type of mark on the program, only the lines marked by the latest operation are shown. The previous marks are not lost but those lines are hidden.

The opposite of compressing lines is expanding them. This returns the display to normal, showing all lines. It keeps the cursor on the marked line it was on when you expanded it.

Copying Marked Lines to a New File

When you compress code, as described above, only marked lines are displayed. You can copy these marked lines to a new editing window, by right clicking on a compressed line and selecting New file from compressed from the popup menu. You can then view, edit, or print these lines; or you can save the file as a text file, enabling you, for example, to create reports on marked lines.

Autocompleting Data Names and Procedure Names

If you have partially entered a data name or procedure name in a program, you can request to see a list of the previously-defined data names and procedure names that most closely match the part of the name you have entered so far. With the list displayed, selecting the name you want inserts it at the relevant position in your program.

How to ...

Autoinserting and Removing Line Numbers

By default, lines in source code are not numbered. You can specify that lines are numbered, and whether the lines are numbered on the left side of the source code (COBOL numbering) or the right side of the source code (standard numbering). You can also specify whether numbering and renumbering take place when the source code is saved.

If you have specified that source code is to be numbered, you can renumber at any time by right clicking on the source code and selecting Renumber from the pop-up menu.

If you want to remove the line numbers, you can right click on the source code, and select Unnumber from the pop-up menu.

The style of numbering (and unnumbering) is selected on the Profile tab of the Edit Options dialog, which is displayed by clicking Options > Edit. On this dialog you can set numbering to COBOL (left side) style, or to standard (right side) style, or to both styles; and also, if you check the Autonumber box, set whether numbering and renumbering occurs when the source is saved.

The choices you make also effect the unnumber facility. If COBOL style numbering is set in the Edit Options dialog, the unnumber option removes numbers in that style, and similarly for standard style numbering. Therefore, if your source code was previously numbered in a COBOL style, and the numbering options are currently set to standard style, unnumbering will not remove the COBOL style numbers. To remove the numbers, you would need to display the Edit Options dialog and set the numbering options on the Profile tab to COBOL style, and then use the unnumber option again.

Editor Navigation Bar

The editor navigation bar provides a quick way to navigate around your source code. The editor navigation bar is provided on the right side of the editor window. The frame is slightly wider here to enable the placement of markers - short, horizontal lines - that provide a visual guide to the location of:

The length of the navigation bar represents the total length of your program. The markers represent the position of the errors, breakpoints and bookmarks in your source code in proportion to the length of the navigation bar. For example, in the figure below:

Editor Navigation Bar with Markers

Figure 6-1: Editor Navigation Bar with Markers

If you double click on a marker, the line containing that marker is displayed, and the cursor placed in that line.

If you hover your cursor over:

Working with SPF Editing

Mainframe Express includes an emulation of the mainframe SPF editing facility. This enables you to use many of the mainframe SPF editing features when editing your source code.

Customizing the Keyboard for SPF Editing

There is a predefined SPF editing keyboard shortcut scheme that you can load. You can customize this scheme to suit your editing preferences. See the topic SPF Editing for information on the keystrokes associated with SPF editing.

Using SPF Primary and Line Commands

You execute SPF primary commands from the SPF Primary Command dialog box. The SPF Primary Command dialog box is a dockable window in the IDE. You can perform the following tasks with primary commands:

You execute SPF line commands from the line command area in the text editor window. You can perform the following tasks with line commands:

See the help topics Supported SPF Editing Commands and Unsupported SPF Editing Commands for more information on SPF commands.

Non-text Hexadecimal Characters in COBOL Programs

COBOL source code can contain non-text characters; that is, characters that can be coded in hexadecimal but have no displayable character associated with them. You can code non-text hexadecimal characters in your COBOL programs in two ways:

Embedded non-text hexadecimal characters in your programs can cause the following issues:

By using Micro Focus tools for file transfer, editing and compiling, these issues can be handled correctly in most circumstances. However, we strongly recommend that you follow the ANSI standard and use the X'xx' syntax wherever possible.


Copyright © 2006 Micro Focus (IP) Ltd. All rights reserved.