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
QB-compatibility: ON ERROR GOTO <label>
In addition a short test program:
Moving the FileErrorTrap to the SUB results in a correct compilation.
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
-
- Posts: 27
- Joined: Jul 07, 2005 12:37
- Location: Malone, NY
- Contact:
QB-compatibility: ON ERROR GOTO <label>
The same problem exists in the 0.20b Windows version.