Formatting COBOL code

Enterprise Developer offers commands and preferences for formatting COBOL code. Formatting means applying consistent indentation and new lines, removing any extra white spaces, aligning keywords and improving the source's readability. As well as these preferences to improve the layout of your code, code clean up is an additional formatting option that ensures consistent COBOL usage when abbreviations are permitted (for example, PIC instead of PICTURE, COMP instead of COMPUTATIONAL, etc...). You can format entire programs, files or a selection of code in the editor. You can also mark portions of code that are not to be formatted.

These settings are stored collectively in 'formatting' and 'code clean up' profiles. For each type of profile, a default Micro Focus [built-in] profile is supplied with Enterprise Developer; it contains the most commonly-used format settings, and by default, is assigned to you when you open a new workspace. You can edit this profile to suit your preferences, or you can create one or more new profiles. Profiles are workspace-specific, and can be exported and distributed to other workspaces or to other users, which may be useful when implementing a company-wide formatting standard, where all users are able to use the same profile to format their code to a consistent standard.

If you have a program that includes sections of code that you do not want to format you can use one of the following options to ensure that only the desired sections are formatted:

  • Comments - comments are not affected by formatting. In the example below the code after the comment will not be formatted:
          *> 01 var1 pic x(30).
  • cblformat - you can exclude sections of code within a program from being formatted, if you surround them with a *> cblformat statement. To indicate the start of the code area that must not be formatted, enter the following:
          *> cblformat off
          ... code below this line will not be formatted...

    To indicate the end of the area which must not be formatted, enter the following:

          *> cblformat on
          ... code below this line will be formatted...