Debugging the Current File

Important:
  • This functionality requires a licensed version of a Rocket Enterprise Developer product on the same machine. See Installation for details.
  • This is not supported in JVM COBOL code. Native COBOL, .NET COBOL, and PL/I code is supported.

Visual Studio Code displays (Debug COBOL Program)for COBOL files or Debug PL/I Program for PL/I files) in the top right corner of the editor task bar. This button enables you to start running or debugging the program which is currently opened in the editor as part of a folder as follows:

Before debugging starts, Visual Studio Code compiles the file, either by running the compiler using the default directives specified in the extension settings, or by using a task specified in the tasks.json file.

When no tasks.json file is available

If your workspace does not include a tasks.json file, Visual Studio Code automatically compiles the current file with the directives specified in the Micro Focus COBOL: Default Directives or Micro Focus PL/I: Default Directives setting of the extension depending on the file type, before it starts debugging.

When tasks.json is available

If tasks.json is present, it can include a task with the suffix (compileCurrentFile) to be able to compile the active file. You need to specify any Compiler directives in the args parameter. For example, for COBOL:

        {
            "label": "COBOL: (compileCurrentFile)",
            "type": "COBOL-shell",
            "windows": {
                "command": "cobol.exe",
                "args": [
                    { "value": "${file}", "quoting": "escape"},
                    { "value": "anim", "quoting": "strong"},
                    { "value": "nognt", "quoting": "strong"},
                    { "value": "errformat(3)", "quoting": "strong"},
                    { "value": ";", "quoting": "strong"} 
                ]
            },
            "linux": {
                "command": "cob",
                "args": [
                    { "value": "${file}", "quoting": "escape"},
                    { "value": "-C", "quoting": "strong"},
                    { "value": "errformat(3)", "quoting": "strong"},
                ]
            },
            "problemMatcher": "$COBOLErrFormat3",
            "group": "build"
        }

Or, for PL/I:

        {
            "label": "PL/I: (compileCurrentFile)",
            "type": "PLI-shell",
            "windows": {
                "command": "mfplx.exe",
                "args": [
                    { "value": "${file}", "quoting": "escape"},
                    { "value": "-debug", "quoting": "strong"},
                    { "value": "-dc", "quoting": "strong"},
                    { "value": "-stbout", "quoting": "strong"},
                    { "value": "-o", "quoting": "strong"},
                    { "value": "${fileBasenameNoExtension}.exe", "quoting": "escape"}
                ]
            },
            "linux": {
                "command": "mfplx",
                "args": [
                    { "value": "${file}", "quoting": "escape"},
                    { "value": "-debug", "quoting": "strong"},
                    { "value": "-dc", "quoting": "strong"},
                    { "value": "-stbout", "quoting": "strong"},
                    { "value": "-o", "quoting": "strong"},
                    { "value": "${fileBasenameNoExtension}", "quoting": "escape"}
                ]
            },
            "problemMatcher": "$PLIShell",
            "group": "build"
        },

In addition, if you use an MSBuild project file, you can create a build task containing compileCurrentFile that uses the MSBuild project file. This task compiles the active file in the editor. For example:

{
    "version": "2.0.0",
    "tasks": [
        {
            "type": "COBOL-MSBuild",
            "command": "C:\\Program Files (x86)\\Microsoft Visual Studio\\2019\\Professional\\MSBuild\\Current\\Bin\\MSBuild.exe",
            "buildTarget": "${workspacefolder}/test.cblproj",
            "problemMatcher": [
                "$COBOLMSBuild"
            ],
            "group": "build",
            "label": "COBOL: MSBuild (compileCurrentFile)",
            "args": [
                "/t:CompileSelected",
                "/p:CompileItems=${fileBasename}"
            ]
        }
    ]
}

Or, for PL/I:

{
    "version": "2.0.0",
    "tasks": [
        {
            "type": "PLI-MSBuild",
            "command": "C:\\Program Files (x86)\\Microsoft Visual Studio\\2019\\Professional\\MSBuild\\Current\\Bin\\MSBuild.exe",
            "buildTarget": "${workspacefolder}/test.pliproj",
            "problemMatcher": [
                "$PLIMSBuild"
            ],
            "group": "build",
            "label": "PL/I: MSBuild (compileCurrentFile)",
            "args": [
                "/t:CompileSelected",
                "/p:CompileItems=${fileBasename}"
            ]
        }
    ]
}