简体   繁体   English

如何在 VS 代码中编译和运行我的 Pascal 代码?

[英]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?有没有办法可以修改 tasks.json 和 keybingings 来创建用于编译和运行代码的快捷方式? 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.当我按 ctrl+shift+b 时,它会编译但没有弹出程序的命令提示符。

"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\""]
    }
]

} }

Pascal is stil alive and kicking.帕斯卡还活着,还在踢。 What I meant by Pascal is the modern object Pascal programming, not your daddy's Pascal.我所说的 Pascal 是现代对象 Pascal 编程,而不是你爸爸的 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).我一直在为所有平台使用(主要是) Free Pascal制作许多应用程序,使用Lazarus IDE (用于 GUI 应用程序)和 VS Code(用于非 GUI 应用程序)。 Modern Pascal can do whatever every other languages out there are able to do.现代 Pascal 可以做任何其他语言都可以做的事情。 Check out The Big 5 Pascal of Today .查看当今的 5 大帕斯卡

Now… to be able to work use Pascal with VS Code.现在……为了能够在 VS Code 中使用 Pascal。 First, install Free Pascal for sure.首先,请务必安装 Free Pascal。 Then install the OmniPascal extension.然后安装OmniPascal扩展。 And read my guide Free Pascal and VS Code .并阅读我的指南Free Pascal 和 VS Code I provide many useful tasks in there to help you work with Pascal, including code formatting.我在其中提供了许多有用的任务来帮助您使用 Pascal,包括代码格式化。 It's in Indonesian but you could use Google Translate to read it in English (or whatever language you like).它是印度尼西亚语,但您可以使用谷歌翻译以英语(或您喜欢的任何语言)阅读。

HTH.哈。

this is my tasks.json and it works very well这是我的tasks.json,效果很好

{
    "version": "2.0.0",
    "tasks": [
        {
            "type": "shell",
            "label": "PAS build active file",
            "command": "fpc",
            "args": [
                "${file}"
            ],
            "group": {
                "kind": "build",
                "isDefault": true
            },
            "problemMatcher": []
        }
    ]
}

FreePascal Toolkit是用于开发 FreePascal 应用程序的 VSCode 扩展。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM