Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I compile and run my Pascal code in VS code?

Is there a way I can modify tasks.json and keybingings to create shortcuts for compiling the code and running it? After a ton of googling I came up with this. When I press ctrl+shift+b it compiles but command prompt with the program doesn't pop up.

"version": "0.1.0",
"isShellCommand": true,
"showOutput": "always",
"command": "cmd",
"args": ["/C"],
"tasks": [
    {
        "taskName": "Compile",
        "suppressTaskName": true,
        "isBuildCommand": true,
        "args": ["\"fpc ${file}\""]
    },
    {
        "taskName": "Run",
        "suppressTaskName": true,
        "isBuildCommand": true,
        "args": ["\"start $[fileBasenameNoExtension}.exe\""]
    }
]

}

like image 700
Chen Guevara Avatar asked Jan 03 '17 20:01

Chen Guevara


2 Answers

Pascal is stil alive and kicking. What I meant by Pascal is the modern object Pascal programming, not your daddy's Pascal. I've been making many apps for all platforms using (mainly) Free Pascal, with Lazarus IDE (for GUI apps) and VS Code (for non-GUI apps). Modern Pascal can do whatever every other languages out there are able to do. Check out The Big 5 Pascal of Today.

Now… to be able to work use Pascal with VS Code. First, install Free Pascal for sure. Then install the OmniPascal extension. And read my guide Free Pascal and VS Code. I provide many useful tasks in there to help you work with Pascal, including code formatting. It's in Indonesian but you could use Google Translate to read it in English (or whatever language you like).

HTH.

like image 144
Bee Jay Avatar answered Nov 15 '22 08:11

Bee Jay


this is my tasks.json and it works very well

{
    "version": "2.0.0",
    "tasks": [
        {
            "type": "shell",
            "label": "PAS build active file",
            "command": "fpc",
            "args": [
                "${file}"
            ],
            "group": {
                "kind": "build",
                "isDefault": true
            },
            "problemMatcher": []
        }
    ]
}
like image 36
David0403 Avatar answered Nov 15 '22 09:11

David0403