Checking VBScript syntax [closed]
Asked Answered
T

5

8

Any good utilities out there for verifying VBScript syntax without actually running the script?

What I'm getting at is if I do something like:

If (year == "2005" && type == 1) Then
...
End If

Is there a tool that will tell me that the '&&' really should be 'And' and the '==', just '='?

Thirtytwo answered 18/8, 2009 at 19:6 Comment(0)
G
0

Actually, I think there is a way. The Script Control includes an Execute method similar to HTML VBScript's Eval method. You can give it a string and it will syntax check it.

You can still get it from here. http://www.microsoft.com/downloads/details.aspx?FamilyID=d7e31492-2595-49e6-8c02-1426fec693ac&displaylang=en

This old MSDN article describes how to add Scripting to your Apps. http://msdn.microsoft.com/en-us/magazine/cc302278.aspx

MSDN Article on the Script Control http://msdn.microsoft.com/en-us/library/aa227633(VS.60).aspx

Something like this.. (not sure of the instantiation)

Dim ScriptControl1 as New MSScript
ScriptControl1.ExecuteStatement “If (year == "2005" && type == 1) Then..End If” 
Guck answered 24/9, 2009 at 21:12 Comment(0)
L
9

If you don't want to run your script because you don't want it to actually do anything, then one method I've used is to put in a "WScript.Quit" statement at the beginning of the script (after the Option Explicit if there is one) then run it using cscript.exe or wscript.exe.

For example:

Option Explicit
WScript.Quit
Dim year
If (year == "2005" && type == 1) Then
    WScript.Echo "Hello"
End If

This won't capture undefined variables (like "type" above), but it's an easy, quick way to check you've got the right syntax.

Lasso answered 17/3, 2012 at 12:0 Comment(0)
C
0

Visual Studio (2005 for sure) will do syntax highlighting and give you IntelliSense for registered dlls, which gets you awfully close to verified syntax.

Other than that, it's an interpreted language so there's only so much you can do. Even the best case scenario only guarantees an "it works on my machine" state.

Creeper answered 18/8, 2009 at 19:55 Comment(0)
D
0

i do not think theres any converter available unfortunately but considering that vbscript syntax is fairly easy you probably can convert it fairly easily

Done answered 26/8, 2009 at 13:22 Comment(0)
G
0

Actually, I think there is a way. The Script Control includes an Execute method similar to HTML VBScript's Eval method. You can give it a string and it will syntax check it.

You can still get it from here. http://www.microsoft.com/downloads/details.aspx?FamilyID=d7e31492-2595-49e6-8c02-1426fec693ac&displaylang=en

This old MSDN article describes how to add Scripting to your Apps. http://msdn.microsoft.com/en-us/magazine/cc302278.aspx

MSDN Article on the Script Control http://msdn.microsoft.com/en-us/library/aa227633(VS.60).aspx

Something like this.. (not sure of the instantiation)

Dim ScriptControl1 as New MSScript
ScriptControl1.ExecuteStatement “If (year == "2005" && type == 1) Then..End If” 
Guck answered 24/9, 2009 at 21:12 Comment(0)
P
0

I'm looking for the same thing. If you happen to be working with vbscript in the context of asp, there is something called http://aspclassiccompiler.codeplex.com/ which apparently compiles your classic asp into asp.net.

Since I believe this gives some kind of compile time errors, I think syntax errors would be reported during compilation. Haven't tried it out yet though.

Purely answered 27/2, 2010 at 0:46 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.