How to comfortably monitor variables in a VBscript during development process? (e.g. in a continuously opened command window)

StackOverflow https://stackoverflow.com/questions/22580977

Question

I need to write a huge VBscript to automatically run an application and I'm looking for a way to comfortably monitor what I'm actually doing, in other words, to display the values of some/all variables involved in my script.

I'm used to work with Matlab, where I have a comfortable workspace browser. When I run a Matlab script, all variables, their types and their values are accessible in that workspace and can be checked.

The VBscript I write with Notepad++ (it needs to be a free editor) and the only way I found to display variables was echoing them via wscript and cscript.


I set up the shortcuts.xml with the following line to run my script directly from Notepad++:

<Command name="Run with CScript" Ctrl="yes" Alt="no" Shift="yes" Key="116">cmd /K %windir%\system32\cscript.exe &quot;$(FULL_CURRENT_PATH)&quot;</Command>

In case I include commands in my script like

Wscript.Echo myVar
Wscript.Echo "Hello World!"

and run it with the newly introduced shortcut, a cmd window pops up and displays the value of myVar and "Hello World!". But the next time I run the script a new window pops up. So my question is:

Is it possible get a continuously opened output window, displaying all echoed values everytime I run a script? I actually want to put the window on a second screen and keep the values from previous runs. So I can enter a line Wscript.Echo something, run, check, enter something else and so on, without fiddling around with a bunch of opened windows.


Alternatively, is there any open-source/free editor which offers an accessible workspace like the one in Matlab?

enter image description here

Was it helpful?

Solution

The open-source editor SciTE offers what I was looking for.

enter image description here

The default settings in vb.properties enable a similar behavior like in Notepad++

command.build.$(file.patterns.wscript)=cscript "$(FilePath)"
command.build.subsystem.$(file.patterns.wscript)=1

One can change it as follows to get the output into the integrated console.

command.go.$(file.patterns.wscript)=cscript.exe //nologo "$(FilePath)"
command.go.subsystem.$(file.patterns.wscript)=0

F5 runs the script and Shift+F5 cleans the output.


Another option is the NppExec Plugin for Notepad++ suggested by @Ansgar Wiechers, which adds a console. The script can be run with cscript.exe /nologo "$(FULL_CURRENT_PATH)" then.

OTHER TIPS

Use a debugger. Start your script with the (meta)option //X. If you are lucky, you already have installed software (MS Office, Visual Studio (Express)) that provides a debugger for VBScript. If not do a bit of research to find an Express version suitable to your OS.

You can almost write native VBScript in the VBA editor, so if you have Excel or whatever you can use this to debug, then go through some steps to convert back to VBScript. That's what I usually do.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top