Workbench COBOL editor
Workbench COBOL Editor is an available option for editing, browsing, and opening actions for files with extensions such as .cob, .cbl, and .cobol. It provides syntax checking, colorization for language syntax, an outline view to assist navigation through the code, code folding functionality, and other functionality that is customized via preference settings. You can also see the elements declared in the copybooks in the outline view under the Include section as well as the main divisions.
To find a text string or EBCDIC hex characters
The editor supports the default Eclipse functionality for finding text. In addition, users can find EBCDIC hex and all occurrences of a text string or EBCDIC hex characters, as described below.
- In the editor, do any of the following:
- Click CTRL+F.
- Highlight the desired search text in the editor and click CTRL+F.
- From the Edit menu, select Find/Replace.
The Find/Replace dialog box appears.
Do any of the following:
- To find a text string, in the Type box, select String.
- To find all occurrences of a text string, in the Type box, select String, then select the Find all occurrences check box.
- To find EBCDIC hex characters, in the Type box, select EBCDIC hex.
- To find all occurrences of EBCDIC hex characters, in the Type box, select EBCDIC hex, then select the Find all occurrences check box.
- Complete the remainder of the dialog box as desired.
- Click Find.
- When searching for all occurrences, the matches are highlighted in the editor and the Search view shows the results. Refer to the Eclipse documentation for information about the Search view.
- When searching for EBCDIC hex characters, the matches (whether in the Search view or in the editor) show the UTF display value based on the currently selected code page. For example, searching for F1F2F3F4F5 finds 12345 when using code page 1047 in the editor.
To use the outline view
- If the Outline view is not already open, from the Window menu, select Show View>Outline. The Outline view displays an outline of the structural elements in the file that is open in the editor.
- Do any of the following:
- To show a variable in the Outline view, click the variable in the editor. The variable is highlighted in the Outline view in the section matching the Data subsection in which it is declared (File Storage, Local Storage, Working Storage, or Linkage).
- Vice versa, to show a variable in the editor, click the variable in the Outline view. The variable is highlighted in the editor.
- To hide variables in the Outline view, click
. Click the toolbar button again to show variables. Variables are shown by default.
- To reparse the Outline view, click
.
- To show all sections of the program (Environment, Data, Procedure) in the Outline view, click
. Click the toolbar button again to show only the Procedure section. All sections are shown by default.
To select a block of code
Toggle Block Selection functionality allows users to select a block of code and then copy it, delete it, or replace it.
- Do one of the following:
- Right-click in the editor and select Toggle Block Selection.
- Within the editor, press Alt+Shift+A.
- Drag the crosshairs to select the desired code.
- Do any of the following:
- To delete the code, click Delete.
- To copy the code, press Ctrl+C. To paste it elsewhere, place the cursor in the new position and press Ctrl+V.
- To replace the code, begin typing
To comment out the dead code, unused copybook, and unused file and Db2 declarations
- Right-click on the editor or the ruler menu and click Quick Fix. Additionally, you can right-click on the error or warning present in the problem view and select the Quick Fix option.
- From the pop-up, select the required option to comment out the dead code, unused copybook, or unused file and Db2 declarations. You can also press ctrl+1 to open the pop-up.
To replace the undefined fields using the suggestion available in the existing program
- Right-click on the editor or the ruler menu and click Quick Fix. Additionally, you can right-click on the error or warning present in the problem view and select the Quick Fix option.
From the pop-up, select the required option to replace the undefined fields using the suggestion available in the existing program. You can also press ctrl+1 to open the pop-up.
To use templates
Templates can be used from within the Workbench COBOL Editor or from the Templates view.
From the editor
- In the editor, place the cursor where the template should be inserted within the COBOL program:
- To list all defined templates, place the cursor after a space.
- To list templates that match a keyword, place the cursor immediately after the keyword.
- To filter the list of templates to those that match typed text, enter the filter text and place the cursor at the end of the desired text
- Press Ctrl+Space. The list of templates appears.
- Select the template to use and press Enter. The template is inserted into the program at the insertion point.
From the Templates view
- From the Window menu, select Show View>Other>General>Templates. The Templates view appears.
- In the editor, position the COBOL program at the desired line.
- In the Templates view, right-click the desired template and select Insert. One of the following occurs:
- The template is inserted into the program at the insertion point.
- If there is input for the selected template, the Input Assistance dialog box appears. Complete the dialog box and click OK. The template is inserted into the program at the insertion point.
Refer to the Eclipse documentation for more information about templates.
To use hover functionality to see a variable's or a copybook's definition
- Open the program in edit or browse mode in the editor.
- If the COBOL source references copybooks, click Yes on the message that appears asking whether to download the copybooks. The copybooks are downloaded. Clicking No prevents copybook download and therefore disables hover functionality for copybooks.
Hover the cursor over the desired variable name or a copybook name in a COPY statement. A tool tip appears showing the definition.
To go to a variable's definition
Do one of the following:
- Right-click the variable and select Open Definition.
- Select the variable and press F3.
If the variable definition is in the same file as the right-clicked variable, the open editor window moves to the line where the definition exists. If the variable definition is in a different file (copybook), then the copybook opens in a separate editor window, positioned at the appropriate line.
To go to a copybook's definition
Do one of the following:
- Right-click the copybook name and select Open Definition.
- Select the copybook name and press F3.
- Hover as described above and press F2 while the tooltip is displayed. Then click
.
The copybook opens in a separate editor window, positioned at the appropriate line.
To change the case of the selected text
- Select the desired text in the editor.
- Right-click the text and do either of the following:
- To change the text to uppercase, select Source>To Upper Case.
- To change the text to lowercase, select Source>To Lower Case.
To identify the scope of a statement
The Workbench COBOL Editor allows users to identify the beginning and end of paragraphs, EXEC SQL (or CICS) and END-EXEC, and a variety of other scopes, such as IF/END-IF, and EVALUATE/END-EVALUATE.
- Select the keyword at the beginning or end of the statement. A box appears around the keyword.
- Click Ctrl+Shift+P. A box appears around the keyword at the opposite end of the statement.
To use code folding functionality
Code folding allows users to select code blocks to be folded (collapsed) so only the first line of code is visible. Conversely, folded code can be unfolded (expanded) code so the entire block of code is visible. The presence of a (minus sign) or
(plus sign) to the left of the code indicates the syntax for which this functionality is available.
- Ensure that code folding is enabled in the preferences. From the Window menu, select Preferences. On the Preferences dialog box, select BMC>Editors>COBOL>Folding, then select the Enable folding check box.
- Optionally, on the Folding page of the Preferences dialog box, select any of the following check boxes to set the initial editor state to be folded. If the check boxes are cleared, the elements will be unfolded.
- Identification Division
- Environment Division
- Data Division
- Paragraphs
- Click Apply and Close.
- Do any of the following:
- To fold code, click the
to the left of the block of code.
- To unfold code, click the
to the left of the line of code.
- To fold all collapsible regions in the program, right-click the line number area and select Folding>Collapse All.
- To unfold all collapsible regions in the program, right-click the line number area and select Folding>Expand All.
- To toggle code folding on or off, right-click in the line number area and select Folding>Toggle Code Folding.
- To display a preview of folded code in a popup window, hover over the
to the left of the line of code.
- To fold code, click the
To comment out/uncomment selected lines of code
- Select the desired lines.
- Right-click and select Source>Toggle Comment. The selected lines are commented out or uncommented, depending on their original state.
To add or remove bookmarks or tasks
The editor supports the default Eclipse functionality for adding and removing bookmarks and tasks. However, markers only persist for files stored in projects, not those opened from Host Explorer. When a marker is added or the editor is closed, a warning message notifies users that the markers will be deleted. This warning can be customized as described below.
Do either of the following:
- To disable the warning message, click the Don't show this warning again check box on the warning message.
- To re-enable the warning message, from the Window menu, select Preferences. Toggle open the BMC node and select Editors. Select the Show warning when adding bookmarks and tasks outside of projects check box..
To view, edit, and insert a character using hex
The Workbench for Eclipse editors allow users to view the value of a non-displayable character, edit a character using hex, and insert a character using hex.
In the editor, do any of the following:
- To view the value of a non-displayable character, highlight the character (represented by ), right-click and select Source>Edit Character using Hex. The Edit Character dialog box appears and the EBCDIC hex value field shows the hex value of the non-displayable character. To change the character, enter its EBCDIC hex value.
- To edit a character using hex, select the character, right-click and select Source>Edit Character using Hex. The Edit Character dialog box appears. Enter the desired value in the EBCDIC hex value field.
- To insert a character using hex, place the cursor in the desired location, right-click and select Source>Insert Character using Hex. The Insert Character dialog box appears. Enter the desired value in the EBCDIC hex value field.
- Click OK.
To edit a single line using hex
The Workbench for Eclipse allows users to edit a single line of characters, including non-displayable characters, using a vertical hex editor.
In the Workbench editor, select the desired line, click
or right-click and select Source>Toggle Hex Line Editor. The hex line editor appears and shows the hex value of the non-displayable characters in a four-line hex display. The first line shows the readable characters; the second and third rows show each character's vertical EBCDIC hex value. When logged in with a code page supporting double-byte characters, the fourth line displays the ideogram for any double-byte characters in the text. The fourth line cannot be used for editing.
- In the hex line editor, use the arrow keys or mouse to select the character to change in either the first line (readable text) or the hex value rows, then enter the new value. To append characters to the end of the line, continue entering data when the cursor is at the end of the line.
To delete text in the sequence number area and the program identification area
The contents of the editor's columns 1-6 (sequence number area) and columns 73-80 (the program identification area) can be quickly and easily deleted.
- In the editor, right-click and select Source>Denumber. The Denumber dialog box appears.
- Select the check boxes for the columns to be denumbered.
- Do either of the following:
- To clear fields that contain only numbers, select Clear numeric fields only.
- To clear all fields, select Clear all fields.
- Click Denumber. The applicable text is deleted from the source file.
To set general preferences
- From the Window menu, select Preferences. The Preferences dialog box appears.
- Toggle open the BMC node, toggle open the Editors node, and select COBOL. The COBOL preferences page appears. The COBOLeditor general settings preferences page appears.
- Select the General tab.
- Do any of the following:
- To show the horizontal ruler, which appears horizontally across the top of the editor window and shows column numbers for every tenth column, select the Show horizontal ruler check box.
- To make the print margin visible in the editor window, select the Show print margin check box and enter in the Print margin column field the column number for the start of the print margin.
- To show the overview ruler, which appears on the right side of the editor, select the Show overview ruler check box.
- To highlight the current line in the editor, select the Highlight current line check box.
- To type in all capital letters, select the Type in ALL CAPS check box. While in the editor, pressing Ctrl+Shift+Z toggles the option. in the status bar indicates that the preference is on; a grayed out icon indicates that it is off.
- To display whitespace characters in the editor, select the Show White Spaces check box.
- To replace the standard caret character used to indicate where the next character will appear with a custom caret, select the Use custom caret check box and, optionally, select the Enable thick caret check box to use a thicker caret.
- To disable hover functionality, which allows users to see a variable's or a copybook's definition by hovering over the variable/copybook within the editor, clear the Activate Hovers check box. By default, the check box is selected and hover functionality is enabled.
- To set the tab width, select the Fixed tab width option and enter the value. The default value for Fixed tab width is 4.
To specify the sequence of tab positions, select the Variable tab stops option and enter the comma-separated positions. By default, the Variable tab stops option is selected and the position is set to 7,8,12,15,18,21,24,27,30,33,36,39,42,45,48,51,54,57,60,63,66,69,73.
5. Click OK.
To turn on syntax checking so that markers are added on lines with syntax errors
1. From the Window menu, select Preferences. The Preferences dialog box appears.
2. Toggle open the BMC node>Editors node> COBOL node, then select Syntax Processing. The Syntax Processing preferences page appears.
3. Check the Enable syntax checking check box.
4. Click Apply.
To set color preferences
- From the Window menu, select Preferences. The Preferences dialog box appears.
- Toggle open the BMC node, toggle open the Editors node, and select COBOL. The COBOL preferences page appears.
- Select the Colors tab.
- To change the colors used in the editor, select the item from the Foreground list and click Color. The Color dialog box appears. Select the desired color and click OK. The changes are reflected in the Preview box.
- To change the font style of text in the editor, select the item from the Foreground list and select the Bold, Italic, Strikethrough, or Underline check box. The changes are reflected in the Preview box.
- Click OK.
To set reference format preferences
The file format of a COBOL source program in the Workbench COBOL Editor is determined based on the specified reference format. The editor supports a Fixed format. Note the following:
- Columns 1 to 6 of the editor are used for line numbers, which are called sequence numbers.
- Column 7 is the indicator column.
- Lines with "/", "D", "d", or "*" in the indicator column are treated as comment lines.
- "D" or "d" in the indicator column indicates that the text following it is debug-related information. This option is valid while debugging build mode is selected.
- Columns 8 to 11 are "area A", and columns 12 to 72 are "area B".
- Column 73 and subsequent columns are the "program identification area".
1. From the Window menu, select Preferences. The Preferences dialog box appears.
2. Toggle opens the BMC node, toggle open the Editors node, toggle opens COBOL, and select Areas. The COBOL editor area settings preferences page appears.
3. In both the Positions 1-6 and Positions 73-80 sections, select or clear the check boxes:
- To disable typing in the selected column range, select the Lock area from editing check box. Clear the check box to enable typing in the selected column range. Selecting this check box enables the Automatically tag updated lines using check box.
- To place a specific tag in the sequence number columns for all edited lines, check the Automatically tag updated lines using check box, and enter the desired text in the field. To leave the sequence number columns blank, clear this check box.
4. Click OK.
To set template preferences
Templates allow users to quickly insert frequently used blocks of code. The Templates preferences page is used to view a list of available templates, information about those templates, and a visual representation of the template. It also allows users to create, edit, remove, import, and export templates. The following describes the fields on the dialog boxes used in these processes:
- Name: The name given to the template.
- Context list: A list of the available contexts.
- Automatically insert check box: Allows the template to be automatically inserted when it is the only available proposal available at the position.
- Description: A short description of the template.
- Preview: Shows a visual representation of the template.
- Insert Variable: This functionality is not currently supported for COBOL templates.
- From the Window menu, select Preferences. The Preferences dialog box appears.
- Toggle open the BMC node, toggle open the Editors node, and toggle open the COBOL node.
- Select Templates. The Templates preferences page appears and displays the templates in the current workspace.
- Do any of the following:
- To disable a template from appearing in any list of available templates (in the editor or in the Templates view), clear the check box in front of the template.
- To create a new template, click New. Complete the New Template dialog box according to the definitions above and click OK. The new template is added to the table on the Templates preferences page.
- To edit a template, select the template and click Edit. Complete the Edit Template dialog box according to the definitions above and click OK. The edits are reflected in the table on the Templates preferences page.
- To remove a template, select the template and click Remove. The template is removed from the table on the Templates preferences page.
- To restore any BMC-provided templates that were previously removed, click Restore Removed.
- To revert a selected template to its BMC-provided state, click Revert to Default.
- To export selected templates, select the templates and click Export. On the resulting dialog box, select the location for the export and click OK.
- To import templates, click Import. On the resulting dialog box, select the location of previously exported templates and click Open.
- To remove any user-created templates and restore all BMC-provided templates to their default states, click Restore Defaults.
- Click Apply and Close.
To set content assist preferences
Content assist offers a pop-up list of choices for completing COBOL code based on the text entered so far. The content assist preferences allow users to set preferences that control content assist behavior.
- From the Window menu, select Preferences. The Preferences dialog box appears.
- Select BMC>Editors>COBOL>Content Assist. The Content Assist page of the Preferences dialog box appears.
- Use the Enable auto activation check box to enable or disable the automatic display of the content assist list. By default, content assist is enabled.
- In the Auto activation delay (ms) field, enter the number of milliseconds Workbench for Eclipse should wait before presenting the content assist pop-up list of choices.