Page 1 of 1

on error

Posted: Tue Jul 05, 2005 1:06 pm
by sid6.7
for the best effect where should the on error goto statement be?
after every input statement? or at the very end of the program...

Posted: Tue Jul 05, 2005 1:38 pm
by MystikShadows
QB and FB imply a local error management. This means that your ON ERROR should be at the start of every subroutine :-).

Posted: Tue Jul 05, 2005 6:11 pm
by sid6.7
so if i dont use subroutines and only use gotos will that work at all?

IE

goto blablah



$$$:
on error goto bleep?
code code
code code
.
.
.
.
end




bleep
print err code
end

thanks mystik...
everytime i use your help i've been adding you to my credits
for each program as a thank you if you dont mind..

Posted: Wed Jul 06, 2005 7:57 am
by {Nathan}
Please use code tags. But to something like this:

Code: Select all

ON ERROR GOTO Error
...
...
...
(an error is here, it goes to error)

Error:

PRINT "There has been an error. We are all screwed."

Posted: Wed Jul 06, 2005 3:10 pm
by Antoni
I'm afraid Mystik Shadows is wrong in this case...
QB4.5 has no LOCAL error handling, whatever the online help says (perhaps a bug) ... Local error handling works only with PDS 7.1..or FB.

The error handling routines must be at the end of the main program, or in the main part of the modules. They can't be in the SUBS/FUNCTIONS in QB 4.5

ON ERROR can be used anywhere the program an error could break it and will be active until an ON ERROR GOTO 0 is found. Some people puts it at the first line of the program and leaves it active until it ends. I don't remember if activating ON ERROR produces any overhead....

In PDS 7.1 and FB you can use ON LOCAL ERROR, allowing you to have error handlers local to SUBS and FUNCTIONS.

Posted: Wed Jul 06, 2005 4:09 pm
by matt2jones
Yeah, for a catch all errorhandler, just put it after you've dimmed all your vars, but before you're program has begun doing things, and have the errorhandler as a label down on the bottom of the main module... or whatever you call the page that you start on. DON'T PUT IT IN A SUB OR FUNCTION, it won't be able to find it.

Well, I managed to repeat everything that was said before me, while adding nothing new to the debate.

What I ment to say was I am one of the Some people [that] puts it at the first line of the program and leaves it active until it[the program] ends

matt blasts his face off with a shotgun.

Posted: Thu Jul 07, 2005 9:44 am
by {Nathan}
Finally.. matt is dead... thank god...