Tips on Building COBOL

Here are some tips on handling projects and building COBOL applications in the Visual Studio IDE:

Add Files to the Project
Right-click the project in Solution Explorer. Choose Add > New Item to create a new file from the supported types in the project directory. To add an existing non-COBOL file, choose Add > Existing Item and browse to the location of the file to select it. This adds a link in the project to the file but does not copy it in the project directory. To add an existing COBOL file, choose Add Existing COBOL Items.
Application Configuration File
Includes the environment variables and COBOL programmable switches used by your native COBOL application at run time. Right-click the project in Solution Explorer and choose Add > New Item > Application Configuration File. To edit the file, right-click it in Solution Explorer and choose Edit. This applies to native projects only.
Assembly / Output name
Choose Project > projectProperties and go to the Application tab. Specify the name of the target file to build and the name of the output assembly in the Assembly name/Output name field.
Build Configuration and Settings
The Visual Studio standard toolbar shows the active build configuration for your project, for example Debug or Release. You can specify settings for a particular configuration on the COBOL tab in your project properties. To create new build configurations or edit the existing ones, choose Build > Configuration Manager.
Building Projects in Parallel
Parallel building in Visual Studio enables you to build multiple projects faster on multi-CPU machines. To optimize the build process, the maximum number of parallel project builds is automatically set to the number of CPUs of your computer, the maximum being 32.

You can configure the number of parallel project builds from Tools > Options > Projects and Solutions > Build and Run.

In order for your multi-project solutions to build in parallel successfully, ensure that the project dependencies and build order are set correctly for your solution using Project > Project Dependencies.

For more details about building projects in parallel in Visual Studio or using MSBuild from the command line, see the Visual Studio help.

Restriction: Parallel builds are not supported with Personal Edition licensing.
Compiling the Files in a Project in Parallel
Restriction: Multi-processor compilation of the sources in a project is only supported for native COBOL. It is not recommended to use with native Object-Oriented COBOL applications.

You can compile your COBOL source code faster on multi-CPU machines if you enable parallel compilation inside a project.

To enable parallel compilation, check the Multi-processor compilation option on the COBOL page in your project's properties. Also, specify the number of Maximum concurrent COBOL compilations option in Tools > Options > Micro Focus > Projects where, by default, the number is automatically set to the number of CPUs of your computer.

COBOL Settings
Use this to set the dialect, the source format and directives for the whole project. Choose Project > projectProperties and select the COBOL tab.
Compiling Stand-alone Files
This only applies to native COBOL. To compile stand-alone files that are not part of a project, right-click in the editor, and click Compile. This produces an .idy file that the IDE uses to enable some editing features such as colorization and navigation. To view or modify the Compiler directives that apply to stand-alone files, right-click in the editor and click Compiler Options. To cancel the compile process, right-click in the editor and click Cancel Compile.

There is limited support in the IDE for stand-alone files. The recommended way to work with Visual COBOL is to include all source files in a project because this enables all IDE features for editing, compiling and debugging. To create a project from a stand-alone file, right-click in the editor and click Create COBOL Project.

Compiler Directives

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. To set directives, choose Project > projectProperties and select the COBOL tab. Click in the Additional Directives field and type the directives, separated with a space.

Copybook Paths
The locations in which the project searches for copybook files. To add copybook paths to the project, choose Project > projectProperties and select the Copybook Paths tab.
Entry Point/Startup Object
Defines the method entry of the application. Choose Project > myProject Properties and select the Application tab. Specify an entry point for your project in the Entry point/Startup object field.
Errors Window
Shows the errors, warning and messages created during edit or compile. Double-click on an error to position the cursor on the line of code that causes the error. You can get Help on the error if you point to the error number in the list and press F1.
Link and Run-Time Environment Settings
Go to the COBOL Link tab in your project properties. To specify environment variables for when you run the project from within the IDE, click Environment on the Application tab in the project’s properties. This is available only for native code.
Output window
Displays the status messages for the executed commands at build time. Display it from View > Output.
Step into inline PERFORM statements when using Step Over
Enable in Tools > Options > Debugging > Micro Focus > COBOL. The default behavior for Step Over (F10) is to skip inline PERFORM statements. Works with native code only.
Stop a Build
Choose Build > Cancel.
Resource Definition Script File
Enables you to add non-executable binary data such as icons, version info, to your executable files. Create the resource script file (.rc) outside of Visual Studio and to add it to your project right-click the project in Solution Explorer and choose Add > Existing Item. This applies to native projects only.