Follow these steps to use your source files in a new project in Visual COBOL. These instructions are correct with Visual Studio 2017:
You can check Create directory for solution in order to give the solution a different name to the project name. This is useful when you are likely to have several projects in the same solution.
Those files are then added to the project in Solution Explorer. These files are copied, not moved, to the project folder in
the file system. If you click the down arrow on the
Add button, you can choose
Add as Link, which adds a reference to the file in the project but neither moves or copies the original. Added files have the icon
; linked files are indicated by the icon
.
You can add copybooks to your projects in the same way as COBOL files, by right-clicking your program, choosing Add > Existing Item and browsing to a copybook. However, it is not compulsory to add copybooks to your project. You can set the copybook dependency paths for your project from the page. Copybooks are not compiled at build time due to the file's Build Action property being automatically set to None. (You can also set this property for COBOL source files too, to keep a file in the project but not include a built version in any output.)
By default, Visual COBOL identifies files as copybooks by their .cpy extension. You can specify other file extensions as copybooks in the IDE preferences - click , and enter the additional values in the text box. Alternatively, you can add the copybook with unknown extension to your project and then reference the file from within a COBOL program using the COPY statement. Visual COBOL then recognizes that extension as a copybook but only across the current solution.
Some Compiler directives are set on project creation, and differ between the Debug and the Release configurations. To add directive to your project, right-click on the project in Solution Explorer and choose Properties. On the COBOL tab, you can see directives that are set by the IDE in the Build Settings text box. Enter others in the Additional Directives text box as a space-separated list.
If you use a separate text file to manage your directives, you can reference this instead by entering the USE"directives file" directive. You should enter a path relative to the project directory.
Having added all the files and made any necessary configuration changes, you can compile and link the COBOL source and generate the output. Right-click the project in Solution Explorer and click Build.
If your source code contains tab stops compilation might fail, as while a COBOL tab is eight characters long, the IDE's tab is four characters long, and lines of code might be starting in the sequence number and indicator areas section (columns one to seven) of the program instead of from column eight.
You can fix this problem using the SOURCETABSTOP(n) compiler directive, where n is the number of space characters by which to expand tab characters during compilation.