Futurebasic/Language/Reference/on error fn

From Wikibooks, open books for an open world
< Futurebasic | Language | Reference
Jump to: navigation, search

Contents

[edit] ON ERROR FN / GOSUB

[edit] Statements

(+) Appearance (+) Standard Console

[edit] Syntax

<code><b>ON ERROR</b> {<b>FN</b> userFunction|<b>GOSUB</b>{<i>lineNumber</i>|<i>"stmtLabel"</i>}}</code>

[edit] Revised

June, 2001 (Release 5)

[edit] Description

This statement designates and enables the routine that FB will call when certain kinds of errors occur. There may only be one ON ERROR vector. If you use a second call to ON ERROR FN, the new routine replaces the old version in subsequent calls. However you can deactivate or reactivate error trapping as often as you need. Using the ON ERROR END/ON ERROR RETURN statements you can switch between the default behavior and your error handler.

Example:

<code><b>LOCAL FN</b> handleFileError<br>
<b>ÊÊPRINT</b> "Sorry. Something has gone wrong."<br>
<b>ÊÊSTOP</b><br>
<b>END FN</b></code>

<code><b>ON ERROR FN</b> handleFileError<br>
<b>OPEN</b> "I",#1,"this file does not exist"</code>

Note:

If you use the ON ERROR FN userFunction syntax, then userFunction must refer to a function which was defined or prototyped at an earlier location in the source code. Your error handling function should not take any parameters, nor return a result.

[edit] See Also

ON ERROR END; ON ERROR RETURN; ERROR function; SYSERROR function

Personal tools
Namespaces
Variants
Actions
Navigation
Community
Toolbox
Sister projects
Print/export