Error handling statement to set the current error handler
Syntax
On Local Error Goto label
Usage
On Local Error Goto label
Parameters
label
label to jump to when error occurs
Description
The
Local clause in an
On Error construction allows to define an error handler in the same
Sub/
Function the
On Local Error is.
Exit Sub/
Function must be used before the start of the error handler.
Notice the program must be compiled with
-e or
-ex option for the QB-like error handling to work.
Example
'' compile with -lang fblite or qb
#lang "fblite"
Declare Sub foo
foo
Print "ok"
Sleep
Sub foo
Dim errno As Integer
On Local Error Goto fail
Open "xzxwz.zwz" For Input As #1
On Local Error Goto 0
Exit Sub
fail: ' here starts the error handler
errno = Err
Print "Error "; errno ' just print the error number
Sleep
End Sub
Differences from QB
- The LOCAL clause comes from PDS 7.1. QB 4.5 does not allow local error handling.
See also