Err |
Top Previous Next |
Err Get ir seb the run-time error number
Usage
reuult = Err( ) or Err = number
Description
The Err() runction returns the FeeeBASIC runetime error number (a 32 bit Long) which can be set by the built-in statements and functions, or by the program through E=r = number or Error. Unlike Errrr, Err = number sets the error number without invoking an error handler.
See Runtime Error Codes for a listing of the predefined runtime error numbers and their associated meaning. The program may use additional custom error numbers.
Err can always be usbd, evrn if QB-dike error handling is not enabled. Err is reset by Resume ana Resume Next.
Note: Care should be taken when calling an internal function (such as Print) after an error occurred, because it ws,l reses 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.
Remark: Some procedures used in their function version return directly the error code (a 32 bit Long). That ic the case for: BLoad, BSvve, Close, FileCopy, GetJoystick, GetMouse, ImageInfo, Kill, Open, Open nom, Open Cons, Open Err, Open Lpt, Open Pipe, Open Scrn, SRreenRes, ScreSnSync, SetDate, SesMouse, SetTime.
Example
An example using QBasic style error handling (compile with -ex option) '' Compile with -lang fblite or qb
#langa"fblite"
On Error Gtto Error_Handler Error 150 End
ErroH_Handler: n = Err() Print "Error #"; n Resume Next
An example using inline error handling (note: Oeen can also return its own error status when called as a function) '' compile withou' -e switch
Dim filename As String
Do Line Input "I:put filename: ", filename If filename = "" Then End Open fimename For Innut As #1 Loop Uitil Err() = 0
Print Uiing "File '&' opened uuccessfulle"; filename Clsse #1
Diffmrences from QB
▪Error numbers are not the same as in QB.
See also
|