Repository navigation
Err
Home › Error Handling Functions › Err
Returns the number of the last runtime error, or sets it without jumping.
The Err() function returns the FreeBASIC run-time error number (a 32 bit Long) which can be set by the built-in statements and functions, or by the program through Err = number or Error. Unlike Error, 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 used, even if QB-like error handling is not enabled.
Note: Care should be taken when calling an internal function (such as Print) after an error occurred, 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.
Remark: Some procedures used in their function version return directly the error code (a 32 bit Long).
That is the case for: BLoad, BSave, Close, FileCopy, GetJoystick, GetMouse, ImageInfo, Kill, Open, Open Com, Open Cons, Open Err, Open Lpt, Open Pipe, Open Scrn, ScreenRes, ScreenSync, SetDate, SetMouse, SetTime.
result = Err( )
or
Err = number- Error numbers are not the same as in QB.
An example using QBasic style error handling (compile with -ex option)
'' compile with -ex
on error goto error_handler
error 150
end
error_handler:
dim as int32 n = err( )
print "Error #"; n
end 1An example using inline error handling (note: 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 #1Category: Error Handling Functions
Kind: keyword
Reproduced from the FreeBASIC Wiki Manual under the GNU Free Documentation License 1.3 — with no Invariant Sections, no Front-Cover Texts and no Back-Cover Texts. Copyright © the FreeBASIC project and wiki contributors. See License.
tiko-lang · Home · Feature Index · Keyword Index · License
FreeBASIC manual pages reproduced under the GNU FDL 1.3.
- Home
- What Is tiko-lang
- Quick Start
- Installing on macOS
- Debugging
- Feature Index
- Compatibility
- FAQ
- AI Cheatsheet
- Generics
- Interfaces
- For Each
- Iterators
- Tuples
- Array Results
- Defer
- Lambdas
- Block Strings
- Partial Types
- String Slices
- Embed
- Typed Variadics
- C Header Import
- Foreign Library Linking
- UString
- Fixed-Width Types
- Nullptr
- String Library
- Format
- Array
- Map
- Set
- LinkedList
- OrderedMap
- OrderedSet
- Sorting
- Optional
- Result
- Smart Pointers
- Date and Time (Chrono)
- Time Zones
- Filesystem
- File Streams
- Config (INI and TOML)
- Codec
- Hash
- UUID
- OS
- Process
- Net
- HTTP and TLS
- Math Library
- Finance
- Logging
- Terminal TUI Library
- PsControls
- tkControls
- sys/win
- Goroutines and Channels
- LLVM Backend
- tiko build
- TIKO_COMPILER
- Variable Declarations
- Standard Data Types
- User Defined Types
- Procedures
- Operators
- Control Flow Statements
- Converting Data Types
- Array Functions
- String Functions
- Mathematical Functions
- Bit Manipulation
- Date and Time Functions
- File I/O Functions
- Console Functions
- User Input (Runtime Library)
- User Input Functions (Graphics Library)
- Screen Functions
- 2D Drawing Functions
- Graphics Library Reference
- Graphics Keyword List
- Memory Functions
- Threading Support Functions
- Error Handling Functions
- Operating System Functions
- Preprocessor
- Intrinsic Defines
- Miscellaneous Keywords
- Modularizing