VBscript syntax check

Posted on 2005-03-04
Medium Priority
Last Modified: 2009-01-23

Is it possile to do a syntax check on a VBscripts ".vbs". I want to be able to check for syntax errors before actaually executing the script.
I know that scripts don't get compiled, so how would you check for syntax problems?  I guess you need some sort of an interpreter?

I don't want to use the script debugger, becuase it will execute the script, right?.  Even though you have the option of stepping through and putting break points....etc, the script will execute.

Before intsalling the script (which does office automation), I want to make sure that it doesn't crash because there is an "If" that does not have and "end if" as an example.

Don't worry I am exeperimenting with an offline machine, so I can not potentially cause damage!!

Sounds simple, but I am a newbie to scripting.


Question by:novice12
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions

Accepted Solution

willcode4coffee earned 800 total points
ID: 13460534
You can run it and if it encounters any compile errors it will display the error in a message box. FrontPage may let you precompile and see errors that occur during the compile, but I am not sure about that.


Author Comment

ID: 13461388

You are telling me that I have to run it, in order for it to do the error check in general.

Not very practical if I have a code consisting of hundreds of lines!. I just don't want to install it until I at least know there is no sytax errors.

I guess there is no way to do this!.


Assisted Solution

scarcas earned 600 total points
ID: 13461535
You could always try VBLaw - it's a commercial product available from http://www.visibleprogress.com/ - we use it in the office to great effect.  The Single user Workstation edition costs less than $100.

I'm unsure whether you can download an evaluation

Assisted Solution

harnal earned 600 total points
ID: 13461583
There is basicly two ways to debug your code.  1 run the script and fix any errors it reports, 2 recheck each line for errors.  Obviously the first is the fastest and most through.  Why would you NOT want to run the script through the script debugger?  

You said its on a test & dev machine, I'm not sure why it's line count has anything to do with debugigng it using a script debugger.  It will only report errors, and the errors code and associated line number.  Very practical and efficient IMO.

Even if you don't have any syntax errors, you may find you have logic errors, or input/output errors that cause inconsistent or incorrect data.  And the only way you're going to discover that is to run the script.

Author Comment

ID: 13462225

Sorry about that, I think I have asked a silly question!

When I said that the line count is high, I was trying to say that it would take some time to review the syntax manually. But you are right it's irrelevant.

I will just run the script in debug mode, after making sure that the machine is completely isolated from the network. I will get errors on network drives mapping (part of the script), but I can skip through using the debugger....


Featured Post

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

When designing a form there are several BorderStyles to choose from, all of which can be classified as either 'Fixed' or 'Sizable' and I'd guess that 'Fixed Single' or one of the other fixed types is the most popular choice. I assume it's the most p…
I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…
Suggested Courses
Course of the Month12 days, 20 hours left to enroll

777 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question