Visual Studio Code displays (Debug COBOL Program)) 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.
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 setting of the extension, before it starts debugging.
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:
{ "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" }
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}" ] } ] }