Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Stop all code 1

Status
Not open for further replies.

Crowley16

Technical User
Jan 21, 2004
6,931
GB
Hi everyone

is there a command that can stop all code from running, without placeing the app into debug mode...

but like the reset option in debug.

the reason I'm asking is that I've got a control calling various functions, however if the first function exits with an error, then I don't want to continue running the rest of the functions.

--------------------
Procrastinate Now!
 
As in a global variable of some description?
[tt]Function FirstF
blnFirstFFailed=True
<... worked ok ...>
blnFirstFFailed=False
End Function

Function SecondF
If blnFirstFFailed Then
Exit Function
Else <... things to do ...>[/tt]



 
I was thinking of something simple and easy to implement...

I have a LOT of functions and hard coding a global condition test into them is just not feasable...

I was thinking there would be something along the lines of the Stop command but one which didn't place me into debuging mode.

--------------------
Procrastinate Now!
 
Can you explain a little more? For example, what happens when the first function fails? Does Exit Function in the first function get you out of the whole thing or are the other functions coming in at different points?
 
Have a look at the End instruction.

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
yep, that's the one PHV...

aragh! you know I even did look at the description for End as well, but somehow missed it?!!

Thanks...

--------------------
Procrastinate Now!
 
Here's a bit of reading on the End statement [ignore]thread222-1177337[/ignore], [ignore]thread222-934000[/ignore], [ignore]thread222-819052[/ignore] - basically there might be some undesireable consequences by using it, it's warned against by Microsoft, most programmers avoid it (some of the reasons to be found in the threads) ...

Now - allow me to be frank - I'm inclined to believe the usage of End here, is just an excuse for sloppy programming. You could test the return values of the functions, or allow the error to "bubble" up to the calling sub or function.

Without any errorhandling in the function, that would happen, and you can handle it in the calling routine. You can also handle the error within the routine, then raise an/the error again from the function - see for instance RickSprs treaty here [ignore]thread222-52018[/ignore]

Roy-Vidar
 
wow, that rickSprs' post certainly is an eye opener...

in my current instance, I think end will be ok since the code isn't loading anything, at least not before the end statement occurs.

however I will certainly be wanting to change my error handling techniques once I get some time... (unfortunately I've been forced to go the "dynamic" route, i.e. go live when you've got something workable and fix bits on as and when people think them up no matter how ill thought out they are and make these changes live asap...)

sorry for the rant there...

--------------------
Procrastinate Now!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top