QB-compatibility: ON ERROR GOTO <label>

General FreeBASIC programming questions.
BasicJan
Posts: 46
Joined: Aug 30, 2005 20:09
Location: Netherlands

QB-compatibility: ON ERROR GOTO <label>

Postby BasicJan » Aug 03, 2008 15:51

QuickBasic requires the error handler (preceded by the label) to be OUTside the SUB or FUNCTION where the ON ERROR GOTO-statement is located.

FreeBasic requires the error handler to be INside the SUB or FUNCTION where the ON ERROR GOTO-statement is located.

If the error handler is placed OUTside the SUB or FUNCTION, next message is returned:
error 47: Undefined label, <label>

The WIKI says that ON LOCAL ERROR GOTO <label> (adding LOCAL) is to be used if the error handler is to be inside the SUB or FUNCTION. I could not find any difference while adding LOCAL or ignoring it.

Compilation commandline:
FBC -lang qb -w 0 -exx -s gui <filename>.BAS

Compiler: 0.18.5b, W32
BasicJan
Posts: 46
Joined: Aug 30, 2005 20:09
Location: Netherlands

Postby BasicJan » Aug 03, 2008 20:14

In addition a short test program:

Code: Select all

DEFINT A-Z
DEFINT a-z

DECLARE SUB TestErrorTrap ()

SUB TestErrorTrap()
  ON ERROR GOTO FileErrorTrap

END SUB

FileErrorTrap:
  SystemError=ERR
  RESUME NEXT


Moving the FileErrorTrap to the SUB results in a correct compilation.
toml_12953
Posts: 27
Joined: Jul 07, 2005 12:37
Location: Malone, NY
Contact:

QB-compatibility: ON ERROR GOTO <label>

Postby toml_12953 » Aug 12, 2008 8:01

The same problem exists in the 0.20b Windows version.

Return to “General”

Who is online

Users browsing this forum: No registered users and 7 guests