Topic : The GFA-Basic Compendium
Author : GFA Systemtechnik GmbH
Version : GFABasic.HYP v2.98 (12/31/2023)
Subject : Documentation/Programming
Nodes : 899
Index Size : 28056
HCP-Version : 3
Compiled on : Atari
@charset : atarist
@lang :
@default : Document not found
@help : Help
@options : +g -i -s +z
@width : 75
@hostname : STRNGSRV
@hostname : CAB
@hostname : HIGHWIRE
@hostname : THING
View Ref-FileON ERROR
ON ERROR GOSUB proc
RESUME [NEXT]
RESUME [label]
proc: procedure name
label: label name
The occurrence of a fault (a TOS or specific fault) normally causes
the output of an error message and an abnormal termination. With ON ERROR GOSUB
there is the possibility of branching to a specified procedure, following the
detection of an error. In the procedure one can then determine the appropriate
reaction to the error.
With the command ON ERROR one switches back to the normal error-trapping, so as
to display the appropriate error message and bring about an abnormal
termination. Under these conditions, therefore, when an error arises, an ON
ERROR command is implemented automatically. In order to be able to react to a
number of errors which occur one after the other, the ON ERROR GOSUB proc
command must be contained within the error-trapping routine.
The RESUME command allows one to react in different ways when errors have
arisen and it is only used in an error-trapping procedure. When used on its own
as 'RESUME', this command causes the error to be repeated. RESUME NEXT
continues execution with the command which follows the command causing the
error. RESUME label causes the program to continue from the point 'label'. The
label for RESUME may be located either in a procedure or in the main program.
If a fatal error occurred (see FATAL), then only RESUME label can be used and
not RESUME NEXT or RESUME without a label.
Example:
ON ERROR GOSUB error_trapping
ERROR 5
PRINT "and again..."
ERROR 5
PRINT "is not reached"
'
PROCEDURE error_trapping
PRINT "Ok, error intercepted"
RESUME NEXT
RETURN
--> The texts 'Ok, error intercepted' is displayed and then 'and again...'.
Then the error message 'Square root only for positive numbers', is brought
about by ERROR 5. The label for RESUME may be located either in a procedure
or in the main program.
Memo: If the label used with RESUME is undefined the compiler will not
issue an error message. Instead the compiler writes a bad binary where
RESUME is translated into JMP 0.l!
If the procedure used with ON ERROR GOSUB is undefined the compiler will
not issue an error message. Instead the compiler writes a bad binary
where ON ERROR GOSUB is translated into JSR 0.l!
The editor does not report a missing procedure with ON ERROR GOSUB.
Division by zero = error code 0
When passed out via pterm() (END) it cannot be detected.
The label for RESUME cannot be located inside a FUNCTION.