如何修复Visual Studio代码,以使其运行并调试简单的基本脚本(.BAS文件)?

发布于 2025-02-02 00:47:26 字数 1506 浏览 4 评论 0原文

背景是

我是一名技术作家,但已经涉足编码多年了。为了工作,我需要测试一百个不同的古代脚本样本。样品存储在我们的文档中。它们是用基本书写的(从技术上讲,在柏树中启用了基本,但与基本脚本相同,基本上非常相似)。我需要对其进行测试并修复任何破裂的内容。

我想设置Visual Studio代码来运行这些代码,因为我喜欢VSC,因为它比我一直使用的产品中包含的非常古老的香草脚本编辑器具有很多好处。

我的需求

主要是,我需要能够将我要测试的代码复制并粘贴到简单的.bas文件中,然后运行并在VSC内部使用代码着色,代码运行和调试器来测试代码。 IntelliSense也将很有帮助。我可以得到颜色编码,但是让它运行并且调试不起作用。

我尝试的内容和其他笔记

我已经花了几个小时尝试设置一些东西,但无法弄清楚。

  • 我从在线发现的内容中有Windows 10
  • ,我将此文件夹c:\ Windows \ Microsoft.net \ Framework64 \ v3.5映射到我的系统路径环境变量。 (其中<用户>是我的用户名)。
  • 我还尝试了不同的VBScript和VBA相关的扩展,但是此后卸载了它们,因为似乎没有解决这个非常基本的(没有双关语)问题。
  • 我在网上和此站点中搜索了各种帖子,但尚未找到解决方案。
  • 我尝试在代码运行中启用在终端中运行,以查看这是否有所作为。

我始终遇到错误,这是错误的。例如,在安装了Code Runner扩展程序后,如果我尝试运行此非常简单的VBScript以显示一个测试消息框...

Sub Main ()
    Dim testString
    testString = "Meh... Will it work?"
    MsgBox testString
End Sub

...我在VSC输出窗口中获得此结果:

[运行] cscript // nologo“ d:\ temp \ vbscripttest.bas”

[完成]在0.174秒内以代码= 0退出

我发现在代码= 0错误上搜索的信息很少,这很有用。

我的脚本在我的d:\ temp文件夹中。我不知道这是否有所作为。如果我尝试通过双击它直接从文件Explorer窗口运行.bas文件,那么什么也不会发生。尽管从图标样式中,它似乎映射到VBScript。

我会收集Windows或VBCode或两者都找不到使事物正常工作的Vbssripting Goodness,尽管我认为将路径变量指向c:\ Windows \ Microsoft.net.net \ Framework64 \ v3.5会解决这个问题。

经过两天的眉毛,使用产品的内部脚本编辑器来测试我的脚本(我的头发已经消失了很久了),我正在为我最喜欢的代码编辑器中的一些老式的调试支持提供了一些良好的老式调试支持!

您建议我做什么使事情正常工作?预先感谢您的帮助。

Background

I'm a tech writer but have dabbled in coding for many years now. For work, I need to test about a hundred different ancient script samples. The samples are stored in our documentation. They are in written in Basic (technically, in Cypress Enable BASIC, but it's essentially very similar if not identical to Basic scripting). I need to test them and fix any that are broken.

I want to set up Visual Studio Code to run these because I love VSC as it has a lot of benefits over the very old and vanilla scripting editor included with our product that I've been using.

My Need

Mainly, I need to be able to copy and paste the code I want to test into VSC into a simple .bas file and then run and test the code inside VSC with code coloring, code running, and a debugger. Intellisense would also be helpful. I can get color coding, but getting it to run and debug isn't working.

What I've Tried and Other Notes

I've already spent hours trying to set something up, but can't figure it out.

  • I have Windows 10
  • From something I found online, I've mapped this folder C:\Windows\Microsoft.NET\Framework64\v3.5 to my system's Path Environment Variable. (where <user> is my user name).
  • I've also tried different vbscript and vba related extensions, but have since uninstalled them as nothing seemed to resolve this very basic (no pun intended) problem.
  • I've searched various posts online and in this site, but haven't found a solution yet.
  • I tried enabling Run in Terminal in Code-runner to see if that made any difference.

Something is wrong, as I consistently get errors. For example, with Code Runner extension installed, if I try to run this very simple vbscript to show a test message box...

Sub Main ()
    Dim testString
    testString = "Meh... Will it work?"
    MsgBox testString
End Sub

...I get this result in my VSC Output window:

[Running] cscript //Nologo "d:\Temp\vbscripttest.bas"

[Done] exited with code=0 in 0.174 seconds

I find very little info searching on code=0 error that is useful.

My script is in my d:\temp folder. I don't know if that makes a difference. If I try running the .bas file from the File Explorer window directly by double-clicking on it, nothing happens. Though from the icon style, it appears to be mapped to VBScript.

I gather either Windows or vbcode or both can't find the vbscripting goodness that makes things work, though I thought pointing the path variable to C:\Windows\Microsoft.NET\Framework64\v3.5 would fix that.

After two days of pulling my eyebrows out using our product's internal script editor to test my scripts (my hair has long since gone), I am hankering for some good old fashioned debugging support in my favorite code editor!

What do you recommend I do to get things working? Thank you in advance for your help.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

你的背包 2025-02-09 00:47:26

您的示例程序正在成功运行。在该文件中,代码路径中没有代码。 vbscript的最高语言(与VBA不同)。这意味着代码在子或功能之外运行。

因此,在第一行main之前插入以调用main。或丢失sub ... end sub vbscript。在VBA/VB6中,您可以选择sub main作为 properties 的启动子。

虽然这不是您的问题,但要完成,如果您在cscriptwscript中使用// B命令行参数,然后消息框未显示。请参阅cscript /?< /code>。

Your sample program is running successfully. In that file there is no code in the code path. VBScript in a top level language (unlike VBA). That means code runs outside of a sub or function.

So insert before the first line Main to call Main. Or lose the Sub ... End Sub for VBScript. In VBA/VB6 you would choose Sub Main as the startup sub in Properties.

While this is not your problem, just to be complete, if you start a script in CScript or WScript using //b command line parameter then message boxes are not displayed. See CScript /?.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文