Place of label in case of error handling.

Windows specific questions.
BasicJan
Posts: 46
Joined: Aug 30, 2005 20:09
Location: Netherlands

Place of label in case of error handling.

Postby BasicJan » Oct 23, 2005 18:05

In case of error handling, a label is used;

ON ERROR GOTO <label>

In case of QuickBasic the label must be outside the SUB or FUNCTION, in case of FreeBasic the label must be inside.

Can this be changed in such a way that FreeBasic accepts placement of the label outside the SUB or FUNCTION as well?

(Looks like the place of DATA-statements which was not QuickBasic-compatible either. This was changed in the 0.15-testing version, making placement of DATA-statements both inside and outside the SUB or FUNCTION possible.)
v1ctor
Site Admin
Posts: 3801
Joined: May 27, 2005 8:08
Location: SP / Bra[s]il
Contact:

Postby v1ctor » Oct 24, 2005 23:48

You just have to declare the error handler label before the function that will reference it with ON ERROR, no forward declaration is allowed.

ON LOCAL ERROR is more safe inside procs than setting a global handler and using ON ERROR GOTO 0 to undefine it.
Antoni
Posts: 1393
Joined: May 27, 2005 15:40
Location: Barcelona, Spain

Postby Antoni » Oct 25, 2005 10:46

v1c:
Are the error handlers separate procedures in FB? If not, i can't figure out how to define the handler BEFORE the ON ERROR. I used to put the handlers after the END of the main program or an EXIT SUB/FUNCTION, but that's AFTER the ON ERROR.

Could you post an example?

Return to “Windows”

Who is online

Users browsing this forum: No registered users and 6 guests