Re: Can I break out of vbScript by causing error..... let me explain

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance



On May 11, 9:01 am, Superfreak3 <Matt.Wal...@xxxxxxxxxxxx> wrote:
On May 10, 8:15 pm, "Michael Harris \(MVP\)" <mikhar.at.mvps.dot.org>
wrote:





The first quick question regards 'On error resume next'. In the docs
it says that this should appear if every called function if the script
is to totally resume on error. Would or should I make the 2 additions
to my current scripts marked by '>' ?

Work with very simplistic samples until you grok the err scoping behavior
:-).

On Error Resume Next
'errors are trapped locally

wscript.echo "before SubA"
Call SubA()
wscript.echo "Err after SubA", err.number, err.description, err.source

Err.clear

wscript.echo "before SubB"
Call SubB()
wscript.echo "Err after SubB", err.number, err.description, err.source

Sub SubA()
'no local errors trapped here!
Err.Raise &hff, "SubAError", "SubA"
wscript.echo "Err in SubA", err.number, err.description, err.source
End Sub

Sub SubB()
'local errors are trapped here!
On Error Resume Next
Err.Raise &hff, "SubBError", "SubB"
wscript.echo "Err in SubB", err.number, err.description, err.source
Err.clear
End Sub

--
Michael Harris
Microsoft.MVP.Scripting

So, if I really don't care if he script kicks out an error, I should
put On Error Resume Next statements in my functions?- Hide quoted text -

- Show quoted text -

So in...

Sub SubB()
'local errors are trapped here!
On Error Resume Next
Err.Raise &hff, "SubBError", "SubB"
wscript.echo "Err in SubB", err.number, err.description,
err.source
Err.clear
End Sub

execution will continue, but in SubA() it will not?

.



Relevant Pages

  • Re: Can I break out of vbScript by causing error..... let me explain
    ... Work with very simplistic samples until you grok the err scoping behavior ... wscript.echo "before SubA" ... wscript.echo "before SubB" ... So, if I really don't care if he script kicks out an error, I should ...
    (microsoft.public.scripting.vbscript)
  • Re: Can I break out of vbScript by causing error..... let me explain
    ... it says that this should appear if every called function if the script ... Work with very simplistic samples until you grok the err scoping behavior ... wscript.echo "before SubA" ... wscript.echo "before SubB" ...
    (microsoft.public.scripting.vbscript)
  • Re: Error handling in vbscript.
    ... Here is my standard schpeal on VBS error handling. ... The Err object appears to be somewhat incorrectly documented in the MS VBS ... look back along the call stack to the global script, ...
    (microsoft.public.scripting.vbscript)
  • Re: PHP file download counter
    ... This will log the request to a flat file then redirect the ... // Class SimpleRedirectLog ... $err = false; ... Write a script that supplies the file download with the correct mime type ...
    (comp.lang.php)
  • Re: setting an environment variable to the current IP
    ... Set WshEnv = WshShell.Environment ... If Err 0 Then ... for each IPConfig in IPConfigSet ... I have enough vbs to have been able to see what the script does, ...
    (microsoft.public.scripting.vbscript)