Re: Err.Description does not contain the full text of the error me

Tech Tip: Click here to run a free scan for Windows Errors and optimize PC performance




"Chad Ullman" <ChadUllman@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:85916340-E73A-40D5-ABFE-1EEB10BA63B0@xxxxxxxxxxxxxxxx
"Pegasus (MVP)" wrote:



Don't use belts and braces. The directive "Option explicit" is sufficient
to
trap undeclared variables - no need to pick them up with an "On Error"
statement.

I predicted this would be the first response to this question. Perhaps I
should have prefaced my questions with this disclaimer: Please don't
assume
I am making a rookie mistake. Yes, I know option explicit will resolve
the
error that is demonstrated, but the code I included is intended to throw
an
error to demonstrate the actual problem, namely the discrepancy between
the
error descriptions from the Err object and the WSH error dialog.

Here is some background:
We have a large set of libraries we have written for use with QTP (an
automated testing tool). I have a script that checks these libraries for
compilation errors. It does this by using Exec to run each script and
trapping any errors. When I get a "Variable is not defined" error, it
would
be far more helpful if it actually told me which variable is undefined,
rather then leaving me to hunt through a few hundred lines of code.

So again, does anyone know why the level of detail is different in the WSH
error dialog and the VBScript Err Object?

Chad

A further thought: Chasing undeclared variables in a VB Script file appears
to be a somewhat futile exercise because in many cases such variables do not
represent an error condition, just an oversight by the programmer that makes
no difference whatsoever to the execution of the program.


.



Relevant Pages

  • Re: Err.Description does not contain the full text of the error me
    ... The directive "Option explicit" is sufficient ... We have a large set of libraries we have written for use with QTP (an ... It does this by using Exec to run each script and ... I think your method of testing for undeclared variables is unsuitable. ...
    (microsoft.public.scripting.vbscript)
  • Re: Err.Description does not contain the full text of the error me
    ... The directive "Option explicit" is sufficient ... We have a large set of libraries we have written for use with QTP (an ... compilation errors. ... It does this by using Exec to run each script and ...
    (microsoft.public.scripting.vbscript)
  • Re: Force wdPrintDocumentWithMarkup
    ... so I get the "Compile Error: ... You have Option Explicit at the top of your module to tell VBA to consider ... undeclared variables as errors. ...
    (microsoft.public.word.vba.general)
  • Re: Function redefinition
    ... > It seems to me that Option Explicit affects only the variable definitions. ... This seems to be an intentional design aspect of the script. ...
    (microsoft.public.scripting.vbscript)
  • Re: Can MInifying vbscript provide performance gain?
    ... In principal, removing white space should make the script run faster, but I ... Binding to local objects, like wshShell or the Dictionary object, is ... I use Option Explicit and declare all variables. ...
    (microsoft.public.scripting.vbscript)