| || |
Problems exiting a script
I have a script that uses a number of
callscripts. In order to properly test
the application I have linked it to a
datapool which produces records for both
valid and invalid data entry.
I have created a function that recognises
when an expected error messgage appears.
What I would like is to be able to quit
the current script without having to generate
an error message (as with sqascriptcmdfailure).
Perhaps I am too new to this product, but is
there a way of doing the equivalent to an
"exit function" from within a script ?
I don't want to convert all my scripts into
functions just so I can have this luxury.
Re: Problems exiting a script
There are a couple of ways to go about what you are describing. It's the not getting an error message that makes it tough.
If you are just using the Sub Main in your scripts then a simple 'Exit Sub' were you want it to exit will work.
If you are calling subs and functions then you would probably have to only use functions. When you exit each function you would have to set a return value that the calling routine would recognize as a forced exit and pass that back down the tree until it got back to the Sub Main in the calling script. I don't think this would be easy to do.
But that just does what you asked to do. What I would suggest for your situation is to have the function that is recognizing the expected error message to return a "True" when it finds (and probably closes) the message box. Then use that returned value as a comparison in some kind of branching logic to decide what to do next.
Something like this:
Result = IsMessageBoxThere ()
If Result = True Then
SQALogMessage sqaNone, "Message box was found", ""
'Do what ever else you would do
'This is the "Normal Exit" section of the sub
'Do whatever clean up that ALWAYS needs to be done in here
Hope that helps and good luck.