Setting Compiler directives for COBOL

You can use directives to control the way the Compiler behaves: what output it produces, what code is compiled and how the compiled code behaves when it runs. For normal operation you need only a few directives. Most of the time, you use the default values.

Important: Setting some directives affects the default setting of other directives. For example, setting one directive might automatically unset another directive, and some directive settings are mutually exclusive.

Within the IDE, you can set Compiler directives at four levels within a project:

  • At the project settings level: from the project properties dialog box, select Micro Focus > Project Settings > COBOL

    Directives set at this level apply to all programs in the current project.

  • Within a build configuration: from the project properties dialog box, select Micro Focus > Build Configurations.

    Directives set at this level apply to programs built by the specific build configuration. Directives set here merge with or override those set in Project Settings.

  • At the folder level (native COBOL only): right-click the folder, and then click Properties. Enable folder specific settings on the COBOL tab and add directives to this screen, or open the COBOL > SQL Preprocessor and COBOL > Additional Preprocessors tabs, and add preprocessor directives in these screens.

    Directives set here apply to all programs within that folder, and they merge with or override those set in the build configuration and project properties.

  • At the program level (native COBOL only): right-click the program, and then click Properties. Enable folder specific settings on the COBOL tab and add directives to this screen, , or open the COBOL > SQL Preprocessor and COBOL > Additional Preprocessors tabs, and add preprocessor directives in these screens.

    Directives set at this level apply to the particular program, and merge with or override those set in the folder properties, build configuration, and project properties.

    Note: You can only specify an SQL preprocessor at file level, if no preprocessor is enabled for the project or for the build configuration.

You can override the process of merging directives from a higher level (project level being the highest, file level being the lowest) by removing all directives inherited from a higher level: on the COBOL properties page, enable configuration specific settings, and then select Override settings from a higher level (instead of merging). If this option is not selected, then the usual behavior of inheritance, as explained above, will continue.

Tip: To display all of the directives in effect for a file, click Display a Compiler directives summary icon (Display a compiler directives summary inside the COBOL editor). This option toggles on/off a 2-line summary at the bottom of the editor, detailing all directives currently set for the file. If this option is not displayed, click Window > Preferences > COBOL > Editor, and then select Show compiler directives summary in editor. You can also set the preferred background color for this summary by selecting the current background color, shown in this section, and selecting a new one from the palette.

Directives set at each of these levels are written to a .mfdirset file. You can apply these files to different levels of your project too; see Configuring directive sets for more information.

In addition, you can also set Compiler directives in a number of other ways, such as within the source code (using the $SET command), on the command line.

Within the IDE, when specifying directives, separate them with a space, and supply arguments either within brackets or quotation marks: for example charset"ascii" dialect(MF), and if you need more than one argument for a particular directive, separate them with a space: for example outdd(sysout 121 r e) or ACTUAL-PARAMS"MyInterface ClassA ClassB".

Important: For applications that use an RDBMS, you might need to set some additional directives in your build configuration.