Revision [15056]

This is an old revision of KeyPgErr made by CountingPine on 2011-03-20 19:00:05.

 

ERR


Error handling function to return the error number of the last error

Syntax:
Usage:
result = Err

Return Value:
After an error, returns the error code that occurred.

Description:
Err can always be used, even if QB-like error handling is not enabled.
NOTE: Care should be taken when calling an internal function (such as KeyPgPrint Print) after an error occurs because it will reset the error value with its own error status. To preserve the Err value, it is a good idea to store it in a variable as soon as the error handler is entered.
See TblRuntimeErrors Runtime Error Codes for a listing of runtime error numbers and their associated meaning.

Examples:
An example using QBasic style error handling (compile with -ex option)
'' Compile with -lang fblite or qb

#lang "fblite"

On Error Goto Error_Handler
Error 150
End

Error_Handler:
  n = Err()
  Print "Error #"; n
  Resume Next

An example using inline error handling (note: KeyPgOpen Open can also return its own error status when called as a function)
'' compile without -e switch

Dim filename As String

Do
    Line Input "Input filename: ", filename
    If filename = "" Then End
    Open filename For Input As #1
Loop Until Err() = 0

Print Using "File '&' opened successfully"; filename
Close #1


Differences from QB:
See also:
Back to Error Handling Functions
Valid XHTML :: Valid CSS: :: Powered by WikkaWiki



sf.net phatcode