Tracking changes with change flags

The editor can insert change flags in the sequence number area of lines that you change in an edit session.

About this task

While editing a file, you can enable change flags. When you first open a file in the editor, change flags are disabled. After you enable them and set the flagging options, the editor inserts a flag into the area configured for change flags. The editor includes several menu options for controlling change flags during an edit session. When you close the file's edit session, these options are reset to their initial state.

For more information about configuring change flags, see the related topics.

Procedure

  • To enable change flags, right-click in the editor and click Start Flagging Changed Lines.
    The Change Flag Insertion window opens. Use this window to set a 3-to-8-character change flag and to choose a language profile. For more information, see Start flagging changed lines.
  • To disable change flags, right-click in the editor and click Change Flag > Stop Flagging Changed Lines.
  • When flagging is enabled, you can choose these actions from the Change Flag menu:
    • Change Base Flag or Profile: Specify a different change flag or choose a different language profile. This menu item opens the Change Flag Insertion window. For more information, see Modifying the base autocomment.
    • Insert Flag on Current Line or Ctrl+Shift+I: Place a change flag on the line where the cursor is. For more information, see Forcing autocomment insertion.
    • Remove Flag from Current Line or Ctrl+Shift+C: Remove the change flag from the line where the cursor is. For more information, see Removing autocomments from changed lines.
    • Force Flag on Last Line Changed: Add a flag to the last line that you changed. For more information, see Forcing autocomment insertion.
    • Start or Stop Displaying Information Messages: Enable or disable information messages that explain why changed lines are not flagged. In the Preferences window, you can define conditions under which changes are flagged, for example, by disabling flags on blank lines. If you add a blank line when flagging blank lines is disabled, the editor displays the message Line ## is Blank. No Autocomment Placed..
      Note: Although the COBOL and PL/I Editors provide this menu item, it has no effect because these editors do not contain an information area.

Hexadecimal editing

Using the Toggle Hex Editing action in the editor toolbar, you can display the hexadecimal (hex) values for the selected line of text.

About this task

Restriction: Hexadecimal editing is not available when you edit EBCDIC DBCS code.

The hex values are displayed at the bottom of the editor in a table format. There are two rows, the first being the highlighted text and the second the hex value of the line. You can change the hex values in the table and the change is reflected in the text. Changes that are made to the character text are also reflected in the hex representation of the text.

After the hex editing function is enabled, you can select different lines in the file and the hex representation is shown at the bottom of the editor. To disable hex editing, click Toggle Hex Editing in the toolbar.

Adding and removing comments

You can quickly add or remove comments for one or more lines in the COBOL Editor by using the Toggle Comment action or Ctrl+/ keyboard shortcut.

Procedure

  1. To add comments:
    1. Highlight one or more lines that you want to make into a comment.
    2. Right-click and click Source > Toggle Comment.
  2. To remove comments:
    1. Highlight one or more comment lines from which you want to remove the comment tag.
    2. Right-click and click Source > Toggle Comment.

Formatting your program

To improve the appearance and readability of your source code, you can set format specifications. When you set format specifications, you can enter your code without concern about the format and then use the Format action in the editor to format the code according to the specifications.

Before you begin

Define format specifications on the Formatter preference page. For instructions, see the related topics.
Restriction:
  • You cannot format a source file after running a preprocessor.
  • Indentation formatting is not available when you edit EBCDIC DBCS code.

Procedure

  1. To format an entire source file, right-click in the editor and click Source > Format.
    When you choose to format an entire file in the COBOL and PL/I editors, the editor warns you that the format operation can take a few minutes and gives you the option of canceling the format operation.
  2. To format a selected block of code:
    1. Select the lines of code that you want to format.
      Note: If you press Ctrl+A to select all lines, formatting occurs without warning. If you are editing a large file, the format operation can take a few minutes.
    2. Right-click in the editor and click Source > Format.

Locating matching parenthesis

When you edit a file, you can quickly locate a matching parenthesis if the Highlight matching parenthesis preference is enabled.

Procedure

  1. In the Preferences window, choose one of these options:
    Option Description
    COBOL > Editor To enable matching parenthesis in the COBOL Editor.
    PL/I > Editor To enable matching parenthesis in the PL/I Editor.
  2. Select the Highlight matching parenthesis check box to enable the matching parenthesis function.
  3. Select the highlight color. Click the Color field and select a color from the Color page.
  4. In the editor, place the caret to the right of an open or closed parenthesis. The matching parenthesis is highlighted with the color defined in the Editor preference.

Searching for occurrences of code elements

The search for occurrences action in the editor locates related language elements. You can select an element in the code and other instances are displayed in the Search view and highlighted in the editor. The results from a search occurrence action also contain occurrences present in copy members, include members, and identified preprocessor statements.

About this task

The scope of elements that can be located by using the search for occurrences is different for COBOL and PL/I programs as shown in the following table.
Table 1. Supported program elements
COBOL PL/I
  • Procedural Statement Conditions
  • Procedural End phrases
  • User-defined words
  • IF Statement
  • WHEN statements
  • OTHERWISE statements
  • Matching END statements
  • Variables and labels

In the Search view, read instances and write instances are highlighted differently. Instances that are reads are highlighted in gray and write instances are highlighted in gold.

The mark occurrence and search occurrence actions are similar in that both provide a method to locate related language elements. But they have several differences:
  • Results of a search occurrences operation are included in the Search view along with being highlighted in the editor. The results of a mark occurrence action are included in the editor only.
  • The results of a search occurrences operation include occurrences in copy members, include members, and identified preprocessor statements. These occurrences are not provided in the mark occurrence results.
  • The mark occurrence action is limited to elements selected on the Mark Occurrences preference.

Procedure

  1. In the file, highlight the code element for which you want to locate other occurrences and right-click.
  2. Click Occurrences in Compilation Unit.
    The Search view displays the found occurrences in the file. Instances of the elements are highlighted as follows:
    • Write instances are highlighted in orange.
    • Read instances are highlighted in gray.
  3. To locate the occurrence in the file, double-click in the code element Search view.

Marking occurrences of code elements

The mark occurrences action in the editor locates related language elements in the editor. If Mark Occurrences is enabled, you can select an element in the code and other instances are highlighted.

Before you begin

  1. To define the language elements that are highlighted by the Mark Occurrences action, use the Mark Occurrences preference.
  2. Ensure that the Mark Occurrences action is enabled in the editor toolbar.
If you want to disable the Mark Occurrences action, clear Mark Occurrences in the editor toolbar. This action is enabled by default.

About this task

The Mark Occurrences and Search Occurrences actions are similar in that both provide a method to locate related language elements. But they have several differences:
  • Results of a search occurrences operation are included in the Search view along with being highlighted in the editor. The results of a mark occurrence action are included in the editor only.
  • The results of a search occurrences operation include occurrences in copy members, include members, and identified preprocessor statements. These occurrences are not provided in the mark occurrence results.
  • The mark occurrence action is limited to elements selected on the Mark Occurrences preference.

Procedure

Focus the cursor on an element.
Other instances of the elements are highlighted as follows:
  • Write instances are highlighted in orange.
  • Read instances are highlighted in gray.

Real-time syntax checking of COBOL files

Real-time syntax checking automatically validates the syntax of COBOL code and embedded CICS® and SQL statements.

About this task

Supported Editors:
  • COBOL Editor
  • z System LPEX Editor

The editor performs real-time syntax checking and provides annotations that describe the errors. If an error is found, a warning icon (Exclamation mark in yellow triangle) is displayed. To see the annotation that describes the error, hover your mouse over the icon. The maximum number of errors that are reported is based on the value that is specified for the Maximum number of problems reported per compilation unit option on the Real-Time Syntax Checking preference page. The maximum includes the file content and referenced files.

You can customize the appearance of the annotation. The default appearance is a yellow squiggly line under the detected error. To customize, click Editor > Text editors > Annotation in the Preferences window. Then, select Exclamation mark in yellow triangle Warnings in the annotation types list. Change the appearance by selecting values under Show in. For example, to highlight the error, check the Text as box and select Highlighted from the menu. Use the Color field to define the highlight color.

To turn off real-time syntax checking, select Disable syntax parser on the Real-Time Syntax Checking preference page. To enable or disable SQL annotations, use the EXEC SQL statements preference page.

The editors check for the following error types in COBOL source files:
  • COBOL syntax errors
  • Missing copybook files
  • Undeclared variables
  • CICS syntax errors in EXEC CICS blocks
  • IMS syntax errors in EXEC DLI blocks
  • Ambiguous variable references
  • Unreachable code. This error type is identified in v14.1.6 and later versions of the product.
Limitations:
  • Real-time syntax checking is not a substitute for compiling. Real-time syntax checking can catch most high-level syntax errors, but for full error checking, it is best to compile your source code.
  • For real-time syntax checking to handle COPY statements correctly, the statement must end with a period (.).

Example

The following example shows the annotation for a syntax error.
Division expected instead of this input annotation.
The code contained the following statement:
Syntax error in COBOL program. Statement coded is incorrect.
The IDENTIFICATION statement must contain "DIVISION" instead of "DIV". The annotation appearance is a green highlight.
The following example shows a missing COPYBOOK. The appearance for this annotation is the default appearance.
Annotation for missing COPYBOOK

Temporarily disabling Real-time syntax checking

The toggle button on the menu bar for Real-time syntax checking can temporarily disable Real-time syntax checking for COBOL, PL/I, and JCL files that are edited.

About this task

When the button Real-time syntax toggle button is clicked, Real-time syntax checking is disabled.

When the button Real-time syntax toggle button is clicked again after Real-time syntax checking has been disabled, the preference settings set previously are restored.

Quick fix

The COBOL Editor, JCL Editor, and PL/I Editor provide suggested changes to resolve a warning or error annotation in the editor. To use the quick fix function, the Real-Time Syntax Checking preference must be enabled.

About this task

When a quick fix is available for a warning or error annotation, a light bulb icon is added to the annotation icon. To display the suggested fixes:
  • Place the cursor over the highlighted text. A small pop-up window displays the suggested fixes.
  • Place the cursor on the light bulb icon and left-click.
  • Place the cursor on the highlighted text and press Ctrl+1.
  • Place the cursor over the text, right-click, and select Quick Fix.
  • Place the cursor on the highlighted text and click Quick Fix.
If one of the suggestions fixes the issue, select the item. The highlighted text is replaced with the suggestion.
The table below shows the quick fixes that are available in the COBOL, JCL, and PL/I editor. The CICS/SQL/DLI column indicates the quick fixes that are supported for EXEC CICS, EXEC SQL, and EXEC DLI statements in COBOL and PL/I source files when you use the COBOL Editor and PL/I Editor.
Table 2. Quick fixes available in each editor
Quick fix COBOL PL/I JCL CICS/SQL/DLI
Correct misspelled keywords Yes Yes Yes Yes
Correct misspelled variable names Yes Yes No Yes
Add qualifier to ambiguous variable name Yes Yes No No
Correct misspelled function name Yes No No No
Change copybook or include file resolution settings Yes Yes Yes Yes
Add a paragraph to PERFORM statement Yes No No No
Add a section to PERFORM statement Yes No No No
Search for copybook or include files Yes Yes Yes Yes