How can I start an interactive console for VBS?

五迷三道 提交于 2020-01-01 11:49:10

问题


Very similar to this question:

How can I start an interactive console for Perl?

I just want to be able to start entering VBS statements, one at a time, and have them evaluated straight away, like Python's IDLE.


回答1:


I wrote this a couple years ago. It's based on this blog post (archived here), but with a couple enhancements. Essentially it's a REPL (Read, Execute, Print, Loop) using the Execute statement:

Do While True
    WScript.StdOut.Write(">>> ")

    line = Trim(WScript.StdIn.ReadLine)

    If LCase(line) = "exit" Then Exit Do

    On Error Resume Next
    Execute line
    If Err.Number <> 0 Then
        WScript.StdErr.WriteLine Err.Description
    End If
    On Error Goto 0
Loop

I usually start it with a batch file of the same name (i.e. "vbs.vbs" and "vbs.bat"), like this:

@cscript.exe //NoLogo %~dpn0.vbs



回答2:


You may try to make a debugger (cscript //X your.vbs) work for you, or to start a project of your own - perhaps based on these (first 3?) proposals



来源:https://stackoverflow.com/questions/15087377/how-can-i-start-an-interactive-console-for-vbs

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!