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.

Err is reset by Resume and Resume Next.

NOTE: PRINT ERR after an error occurred is likely to print 0, because PRINT sets a new ERR value when executed. To print an ERR value it must be first copied to an auxiliary variable and print that one.

See Runtime Error Codes for a listing of runtime error numbers and their associated meaning.

Example

An example using QBasic style error handling (compile with -ex option)
'' Compile with -lang fblite or qb
On Error Goto Error_Handler
Error 150
End

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

An example using inline error handling
Dim a As String
Do
Input "Input filename ";a
If a="" Then Exit Do
Open a For Input As #1
Loop Until Err=0


Differences from QB

  • Error numbers are not the same as in QB.

See also