I am trying to add a task to compile a program but am having difficulty with setting environment variables. I have this:
{
// See https://go.microsoft.com/fwlink LinkId=733558
// for the documentation about the tasks.json format
"version": "2.0.0",
"label": "GnuCOBOL - Compile (single file)",
"type": "shell",
"options": {
"env": {
"PATH=c:\\gnucobol3\\bin"
"COB_CONFIG_DIR=c:\\gnucobol3\\config"
"COB_COPY_DIR=c:\\gnucobol3\\copy"
"COB_INCLUDE_PATH=c:\\gnucobol3\\include"
"COB_LIB_PATH=c:\\gnucobol3\\lib"
},
"command": "cobc",
"args": [
"-x",
"-std=mf",
"-tPROG.LST",
"BBCB.CBL"
]
},
}
The env entries all have squiggly lines underneath and show errors "Colon expected".
I'd appreciate some help. Thanks.
The env entries all have squiggly lines underneath and show errors "Colon expected".
Because it expects a contained list which should have colons in and uses commas for separation (identical to the options
variable) [note: that actually is a json issue, using that tag may be reasonable].
See Schema for tasks.json.
Also your script has some file names hard-wired (which is a vscode specific), you'll likely want to use the supported variables instead.
Untested result:
{
// See https://go.microsoft.com/fwlink LinkId=733558
// for the documentation about the tasks.json format
"version": "2.0.0",
"label": "GnuCOBOL - Compile (single file)",
"type": "shell",
"options": {
"env": {
"PATH": "c:\\gnucobol3\\bin",
"COB_CONFIG_DIR": "c:\\gnucobol3\\config",
"COB_COPY_DIR": "c:\\gnucobol3\\copy",
"COB_INCLUDE_PATH": "c:\\gnucobol3\\include",
"COB_LIB_PATH": "c:\\gnucobol3\\lib",
},
"command": "cobc",
"args": [
"-x",
"-std=mf",
"-t${fileBasenameNoExtension}.LST",
"${file}"
]
},
}