mst1
12 years agoOccasional Contributor
Vbscript Err.Number in different files
hello,
I am currently busy with building a TestComplete project using VBScript. The script code is currenlty splitted over different files. I used the 'USEUNIT statement to be able to call functions from another file.
I'm actually experiencing problems with the "global" Err object from vbscript.
The case is as next:
In the first file I have some functionallity and in some cases I am raising an error myself.
After that I call a general (custom) function to check error numbers. This function is defined in the other files. So for example:
FileA:
'USEUNIT FileB
Sub MyFunction
on error resume next 'start local error catching
'raise a custom error
err.raise vbObjectError + 1, "MyFunction", "Customer error"
ErrorChecker 'check for errors and handle them
on error goto 0 'stop local error catching
End Sub
The errorchecker function is defined in FileB:
Sub ErrorChecker
If Err.Number <> 0 Then
'handle the error
Err.Clear
End If
End Sub
However, the raised error is not handled. Step-by-step debugging showed me that:
In fileA the error is raised properly
As soon as the execution reached FileB, the err.number is 0 (and the error is not handled therefore)
As soon as the execution is returned to FileA again, the error is exists (again)
So as far as I can see, the Err object is NOT global in TestComplete, but local per scriptfile.
Does someone know if that's true, and if there is a workaround to make the Err object really global?
Thanks for your reply in advance!
I am currently busy with building a TestComplete project using VBScript. The script code is currenlty splitted over different files. I used the 'USEUNIT statement to be able to call functions from another file.
I'm actually experiencing problems with the "global" Err object from vbscript.
The case is as next:
In the first file I have some functionallity and in some cases I am raising an error myself.
After that I call a general (custom) function to check error numbers. This function is defined in the other files. So for example:
FileA:
'USEUNIT FileB
Sub MyFunction
on error resume next 'start local error catching
'raise a custom error
err.raise vbObjectError + 1, "MyFunction", "Customer error"
ErrorChecker 'check for errors and handle them
on error goto 0 'stop local error catching
End Sub
The errorchecker function is defined in FileB:
Sub ErrorChecker
If Err.Number <> 0 Then
'handle the error
Err.Clear
End If
End Sub
However, the raised error is not handled. Step-by-step debugging showed me that:
In fileA the error is raised properly
As soon as the execution reached FileB, the err.number is 0 (and the error is not handled therefore)
As soon as the execution is returned to FileA again, the error is exists (again)
So as far as I can see, the Err object is NOT global in TestComplete, but local per scriptfile.
Does someone know if that's true, and if there is a workaround to make the Err object really global?
Thanks for your reply in advance!