Revision history for KeyPgOnerror


Revision [21923]

Last edited on 2017-09-29 12:49:43 by fxm [Added (in ยง"See also") a link to the "Labels" page]
Additions:
- ##[[TblRuntimeErrors|Runtime Error Codes]]##
- ##[[ProPgErrorHandling|Error Handling]]##
- ##[[ProPgLabels|Labels]]##
Deletions:
- [[TblRuntimeErrors|Runtime Error Codes]]
- [[ProPgErrorHandling|Error Handling]]


Revision [20344]

Edited on 2016-02-10 16:03:26 by DkLwikki [Update link format]
Additions:
On [[[KeyPgLocal|Local]]] Error Goto //label//
**On Error** triggers a jump to an error handler when an error occurs. Such errors can be triggered by built-in statements such as ##[[KeyPgOpen|Open]]##, or when the ##[[KeyPgError|Error]]## statement is used.
Note: The error checking for built-in statements is only enabled if the program is compiled with one of the //[[CompilerOpte|-e]]//, //[[CompilerOptex|-ex]]// or //[[CompilerOptexx|-exx]]// options. **On Error** remains working with ##[[KeyPgError|Error]]## even when none of these options are used.
##[[KeyPgLocal|On Local Error]]## can be used to specify a local error handler inside a procedure. This allows for specialized per-procedure error handling and will override the global error handler, if any. Without ##[[KeyPgLocal|Local]]##, the handler must be in the main part of the module.
Remark: Presently, the ##[[KeyPgLocal|Local]]## clause is ignored by the compiler.
- ##[[KeyPgError|Error]]##
- ##[[KeyPgLocal|Local]]##
- ##[[KeyPgErr|Err]]##
- [[TblRuntimeErrors|Runtime Error Codes]]
- [[ProPgErrorHandling|Error Handling]]
Deletions:
On [[[KeyPgLocal Local]]] Error Goto //label//
**On Error** triggers a jump to an error handler when an error occurs. Such errors can be triggered by built-in statements such as ##[[KeyPgOpen Open]]##, or when the ##[[KeyPgError Error]]## statement is used.
Note: The error checking for built-in statements is only enabled if the program is compiled with one of the //[[CompilerOpte -e]]//, //[[CompilerOptex -ex]]// or //[[CompilerOptexx -exx]]// options. **On Error** remains working with ##[[KeyPgError Error]]## even when none of these options are used.
##[[KeyPgLocal On Local Error]]## can be used to specify a local error handler inside a procedure. This allows for specialized per-procedure error handling and will override the global error handler, if any. Without ##[[KeyPgLocal Local]]##, the handler must be in the main part of the module.
Remark: Presently, the ##[[KeyPgLocal Local]]## clause is ignored by the compiler.
- ##[[KeyPgError Error]]##
- ##[[KeyPgLocal Local]]##
- ##[[KeyPgErr Err]]##
- [[TblRuntimeErrors Runtime Error Codes]]
- [[ProPgErrorHandling Error Handling]]


Revision [16160]

Edited on 2012-04-18 16:22:38 by FxMwikki [Presently, the 'Local' clause is ignored by the compiler]
Additions:
Remark: Presently, the ##[[KeyPgLocal Local]]## clause is ignored by the compiler.


Revision [16147]

Edited on 2012-03-30 19:14:37 by DkLwikki [Revise, mention Error]
Additions:
On [[[KeyPgLocal Local]]] Error Goto //label//
Label to jump to when an error occurs
**On Error** triggers a jump to an error handler when an error occurs. Such errors can be triggered by built-in statements such as ##[[KeyPgOpen Open]]##, or when the ##[[KeyPgError Error]]## statement is used.
Note: The error checking for built-in statements is only enabled if the program is compiled with one of the //[[CompilerOpte -e]]//, //[[CompilerOptex -ex]]// or //[[CompilerOptexx -exx]]// options. **On Error** remains working with ##[[KeyPgError Error]]## even when none of these options are used.
##[[KeyPgLocal On Local Error]]## can be used to specify a local error handler inside a procedure. This allows for specialized per-procedure error handling and will override the global error handler, if any. Without ##[[KeyPgLocal Local]]##, the handler must be in the main part of the module.
##**On Error Goto 0**## deactivates the current error handler.
- [[ProPgErrorHandling Error Handling]]
Deletions:
**On [Local] Error Goto** //label//
{{fbdoc item="usage"}}##
**On [Local] Error Goto** //label//
label to jump to when error occurs
##[[KeyPgOnerror On Error]]## triggers a jump to an error handler when an error occurs.
If ##[[KeyPgLocal Local]]## is not used the handler must be in the main part of the module. Using ##[[KeyPgLocal Local]]## allows to have the error handler inside the ##[[KeyPgSub Sub]]##/##[[KeyPgFunction Function]]## where the ##**On Error**## is located.
##**On Error GOTO 0**## deactivates the current error handler.
The use of QB-like error handling requires compilation with switch //[[CompilerOpte -e]]//, //[[CompilerOptex -ex]]// or //[[CompilerOptexx -exx]]// activated, otherwise ##**On Error**## is inactive but consumes CPU time (##**On Error**## can be used within a preprocessor conditional directive block depending on the value of ##[[KeyPgDdfberr __FB_ERR__]]## in order not to penalize the execution speed if no error checking option).
See [[TblRuntimeErrors Runtime Error Codes]] for a listing of runtime error numbers and their associated meaning.
{{fbdoc item="lang"}}
- ON ERROR is supported in any //[[CompilerOptlang -lang]]// dialect.
- In the //[[CompilerOptlang -lang fb]]// dialect, statements can be used preferably in function form to return an error code: in that case ON ERROR being ineffective but consuming CPU time must be unused.
{{fbdoc item="filename" value="examples/manual/check/KeyPgOnerror_2.bas"}}%%(freebasic)
'' Compile with FB default (-lang fb) dialect
If Open( "text" For Input As #1 ) <> 0 Then
Print "Unable to open file"
End If
- {{fbdoc item="keyword" value="ProPgErrorHandling|Error Handling"}}


Revision [15253]

Edited on 2011-09-30 06:41:10 by DkLwikki [Add 2nd example]
Additions:
{{fbdoc item="filename" value="examples/manual/error/onerror2.bas"}}%%(freebasic)
'' compile as: fbc onerror.bas -ex
#lang "fblite"
function hFileExists( filename as string ) as integer static
dim f as integer
hFileExists = 0
on local error goto exitfunction
f = freefile
open filename for input as #f

close #f
hFileExists = -1
exitfunction:
exit function
end function
print "File exists (0=false): "; hFileExists( command )
on error goto errhandler
error 1234
print "back from resume next"
end 0
errhandler:
print "error number: " + str( err ) + " at line: " + str( erl )
resume next


Revision [15174]

Edited on 2011-08-09 14:24:00 by FxMwikki [Add 2nd example]
Additions:
- In the //[[CompilerOptlang -lang fb]]// dialect, statements can be used preferably in function form to return an error code: in that case ON ERROR being ineffective but consuming CPU time must be unused.
Deletions:
- In the //[[CompilerOptlang -lang fb]]// dialect, statements can be used preferably in function form to return an error code: in that case ON ERROR being inhibited but consuming CPU time, it must be unused.


Revision [15173]

Edited on 2011-08-09 14:10:25 by FxMwikki [Add 2nd example]
Additions:
The use of QB-like error handling requires compilation with switch //[[CompilerOpte -e]]//, //[[CompilerOptex -ex]]// or //[[CompilerOptexx -exx]]// activated, otherwise ##**On Error**## is inactive but consumes CPU time (##**On Error**## can be used within a preprocessor conditional directive block depending on the value of ##[[KeyPgDdfberr __FB_ERR__]]## in order not to penalize the execution speed if no error checking option).
Deletions:
The use of QB-like error handling requires compilation with switch //[[CompilerOpte -e]]//, //[[CompilerOptex -ex]]// or //[[CompilerOptexx -exx]]// activated, otherwise ##**On Error**## is inactive but consumes CPU time (##**On Error**## can be used within a preprocessor conditional directive block depending on the value of ##[[KeyPgDdfberr __FB_ERR__]]## in order not to penalize the execution speed in case of no error checking option).


Revision [15172]

Edited on 2011-08-08 17:23:04 by FxMwikki [Add 2nd example]
Additions:
- ON ERROR is supported in any //[[CompilerOptlang -lang]]// dialect.
- In the //[[CompilerOptlang -lang fb]]// dialect, statements can be used preferably in function form to return an error code: in that case ON ERROR being inhibited but consuming CPU time, it must be unused.
Deletions:
- ON ERROR is supported in any //[[CompilerOptlang -lang]]// dialect. In the //[[CompilerOptlang -lang fb]]// dialect, statements can be used preferably in function form to return an error code, and in that case ON ERROR being inhibited but consuming CPU time, it must be unused.


Revision [15171]

Edited on 2011-08-08 17:21:32 by FxMwikki [Add 2nd example]
Additions:
The use of QB-like error handling requires compilation with switch //[[CompilerOpte -e]]//, //[[CompilerOptex -ex]]// or //[[CompilerOptexx -exx]]// activated, otherwise ##**On Error**## is inactive but consumes CPU time (##**On Error**## can be used within a preprocessor conditional directive block depending on the value of ##[[KeyPgDdfberr __FB_ERR__]]## in order not to penalize the execution speed in case of no error checking option).
Deletions:
The use of QB-like error handling requires compilation with switch //[[CompilerOpte -e]]//, //[[CompilerOptex -ex]]// or //[[CompilerOptexx -exx]]// activated, otherwise ##**On Error**## is inactive but consumes CPU time (##**On Error**## can be used within preprocessor conditional directive block depending on the value of ##[[KeyPgDdfberr __FB_ERR__]]## in order not to penalize the execution speed in case of no error checking option).


Revision [15170]

Edited on 2011-08-08 16:56:23 by FxMwikki [Add 2nd example]
Additions:
- ON ERROR is supported in any //[[CompilerOptlang -lang]]// dialect. In the //[[CompilerOptlang -lang fb]]// dialect, statements can be used preferably in function form to return an error code, and in that case ON ERROR being inhibited but consuming CPU time, it must be unused.
Deletions:
- ON ERROR is supported in any //[[CompilerOptlang -lang]]// dialect. In the //[[CompilerOptlang -lang fb]]// dialect, statements can be used preferably in function form to return an error code.


Revision [15169]

Edited on 2011-08-08 16:42:33 by FxMwikki [Add 2nd example]
Additions:
The use of QB-like error handling requires compilation with switch //[[CompilerOpte -e]]//, //[[CompilerOptex -ex]]// or //[[CompilerOptexx -exx]]// activated, otherwise ##**On Error**## is inactive but consumes CPU time (##**On Error**## can be used within preprocessor conditional directive block depending on the value of ##[[KeyPgDdfberr __FB_ERR__]]## in order not to penalize the execution speed in case of no error checking option).
Deletions:
The use of QB-like error handling requires compilation with switch //[[CompilerOpte -e]]//, //[[CompilerOptex -ex]]// or //[[CompilerOptexx -exx]]// activated, otherwise ##**On Error**## is inactive but consumes CPU time.


Revision [15168]

Edited on 2011-08-08 16:25:17 by FxMwikki [Add 2nd example]
Additions:
The use of QB-like error handling requires compilation with switch //[[CompilerOpte -e]]//, //[[CompilerOptex -ex]]// or //[[CompilerOptexx -exx]]// activated, otherwise ##**On Error**## is inactive but consumes CPU time.
Deletions:
The use of QB-like error handling requires compilation with switch //[[CompilerOpte -e]]//, //[[CompilerOptex -ex]]// or //[[CompilerOptexx -exx]]// activated.


Revision [15160]

Edited on 2011-08-07 15:44:43 by FxMwikki [Add 2nd example]
Additions:
- {{fbdoc item="keyword" value="ProPgErrorHandling|Error Handling"}}


Revision [15155]

Edited on 2011-08-07 14:47:58 by FxMwikki [Add 2nd example]
Additions:
- ON ERROR is supported in any //[[CompilerOptlang -lang]]// dialect. In the //[[CompilerOptlang -lang fb]]// dialect, statements can be used preferably in function form to return an error code.
Deletions:
- ON ERROR is supported in the //[[CompilerOptlang -lang qb]]// dialect only. In the //[[CompilerOptlang -lang fb]]// dialect, statements can be used in function form to return an error code


Revision [13554]

Edited on 2008-07-21 15:43:21 by JeffMarshall [added #lang or $lang to example]
Additions:
'$lang: "qb"
On Error Goto errorhandler
Error 24 '' simulate an error
Print "this message will not be seen"
Print "Error #"; Err; "!"
End
Deletions:
on error goto errorhandler
error 24 '' simulate an error
print "this message will not be seen"
print "Error #"; err; "!"
end


Revision [13241]

The oldest known version of this page was created on 2008-04-26 09:10:50 by JeffMarshall [added #lang or $lang to example]
Valid XHTML :: Valid CSS: :: Powered by WikkaWiki



sf.net phatcode