To create a COBOL project from existing code

These are the steps to use the Project from Existing Code wizard in Visual Studio to create and configure a project:

  1. Locate the existing COBOL files that you need to import in the Visual Studio IDE.
  2. In the IDE, click Tools > Options > Micro Focus > Directives > COBOL.
  3. Ensure the directives are set as appropriate.

    The directives set on this page are set on imported files. For example, you can choose to set the dialect directive or various SQL directives. After the files are imported in the project, the IDE performs an additional directives scanning of them and sets the directives as necessary.

  4. Ensure any file extensions that are not traditionally associated with COBOL will be recognized as COBOL programs or copybooks.

    Read To associate file extensions with COBOL and To specify that a file extension is a copybook for details.

  5. Click File > New > Project from Existing Code to invoke the wizard.
  6. On the Welcome page, ensure Micro Focus COBOL is selected as the project type to create.
  7. Click Next.
  8. On the Specify Project Location, Project Type and Source Files page, specify a directory, a name and an output type for the Visual Studio project.

    You do not need to specify the cblproj extension in the name as the wizard adds it automatically.

  9. Specify the folders that contain the source files to import into your project:
    1. Click Add.
    2. Browse to the folder that contains the source files and select it.
    3. Click Select Folder.
    4. Check Add subfolders if you want to add files from all subfolders.
    5. Repeat and add other folders as needed.
  10. Ensure File types to add to the project lists all file extensions that you want to add to your project.
  11. Check Add copybooks to Solution Explorer if you want to show the copybook files as part of the project in Solution Explorer.
  12. Click Next.
  13. On the Specify New COBOL Project Properties page, specify whether to create a native or a managed project.
  14. For native projects, select the target platforms.
  15. Click Finish.

    Visual Studio starts importing the files which is an asynchronous process so the IDE will be unresponsive to any other events till the import is complete.

    During file import, the wizard:

    1. Creates a Visual Studio project in the specified directory.
    2. Scans the files in the source folders to determine which ones are COBOL programs and which are copybooks.
    3. Imports the files of the selected file types into your project:
      • If the source files are in the same folder, the wizard adds them to the project and re-creates the subfolder structure.
      • If the source files are stored in other folders, the wizard only links them to your project.
    4. Adds the paths to the source folders that contain copybook files to the COBCPY environment variable as paths relative to the project.

      To see what paths are set for the project, click Project > ProjectName Properties and check the Copybook Paths tab.

    5. Adds the copybooks to the project in Solution Explorer (if you specified this in the wizard).
    6. Sets the Compile build action on files which it identified as COBOL programs.

      Copybook files do not compile so no build action is set on them.

    7. Performs a directives scan of the imported files and sets additional directives as specified in Tools > Options > Micro Focus > Directives.
    8. Displays a summary report about the files it imported, the directives and copybooks paths that it set in the Output window.
  16. Check the Output window for summary report of the actions the wizard performed. From the drop-down list next to Show output from choose:
    • Import Files Results - shows a list of the files that were imported and the copybooks paths that were added to the COBCPY environment variable.
    • General - shows results from the file scan and the directives that were set as specified in Tools > Options > Micro Focus > Directives.