skip to Main Content

I’m trying to build files in vscode with an "unsupported" compiler. Therefore I’ve created a task to start the compiler and this works perfectly, as long as the source and destination files are given. I give my source file as ${file} and vscode correctly substitutes this with the source file. For the destination file I have to use the same filename but change it’s extension.

Is it possible for me to create a string variable in .json, copy the value of my ${file} string into that and use change its extension before using it as an argument?

My tasks.json is below, my sourcefile ${file} = "C:_projectsCustomerLoggingLogAsyncASyncLogServer.kl"

{
    "version": "2.0.0",
    "tasks": [
        {
            "label": "Build",
            "type": "shell",
            "command": ".\ktrans.exe",
            "problemMatcher": [],
            "options": {
                "cwd": "C:\Program Files (x86)\FANUC\WinOLPC\bin\"
            },
            "args": [
                "${file}",
                "C:\_projects\Customer\Logging\LogAsync\ASyncLog\Server.pc"
            ],
            "group": {
                "kind": "build",
                "isDefault": true
            }
        }
    ]
}

2

Answers


  1. Chosen as BEST ANSWER

    Thanks all for helping. My working code is below for other peaple who came here searching for how to compile Fanuc Karel in vscode:

    {
        "version": "2.0.0",
        "tasks": [
            {
                "label": "Build",
                "type": "shell",
                "command": ".\ktrans.exe",
                "problemMatcher": [],
                "options": {
                    "cwd": "C:\Program Files (x86)\FANUC\WinOLPC\bin\"
                },
                "args": [
                    "${file}",
                    "${fileDirname}\${fileBasenameNoExtension}.pc" 
                ],
                "group": {
                    "kind": "build",
                    "isDefault": true
                }
            }
        ]
    }
    

  2. Yes, you can use ${file} to generate an output "arg" for a task in vscode. To do so, simply add the following line to your tasks.json file:

    "args": ["${file}"]

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search