We use cookies to ensure that we give you the best user experience on our website.If you want to find out more about the cookies we use, you can access to our Privacy Policy here.By continuing your visit to our website, we'll assume you consent to our use of cookies.

DENSO DENSO WAVE

Close

Technical Information

Application Development Manual | Processing run-time errors (error trapping)

Processing run-time errors (error trapping)

Function

Use error trapping to process run-time errors in programs.

Syntax

Detailed Description

Run-time errors frequently accompany communications and other operations even during normal use, so such user application programs should use error trapping to provide their own built-in recovery processing.

The ON ERROR GOTO statement specifies a label giving the starting point for this processing whenever there is a run-time error. Alternatively, specifying 0 disables error trapping.

Returnlocation specifies how the recovery processing returns the program to normal processing. (See Table.)

Setting Return target after error processing
Blank Statement triggering run-time error
0 Statement triggering run-time error
NEXT Statement following one triggering run-time error
Other label Line specified by the label

The ERR and ERL functions provide additional information about the run-time error and its location. The error processing routine can branch on the error type, for example.

Example

Retry if a file transfer encounters an error

  private tempkey$         ' declare variable
open "COM1:115200" as #1 ' open communications device file
out &h6060, 3
on error goto ERRCOM     ' branch to ERRCOM on communications errors
xfile "TEST1.DAT"        ' Send file
on error goto 0
close #1
end
ERRCOM:
print "Transmission error!"
print "CODE:";hex$(ERR);
print " ADDR:";hex$(ERL)
print "Press a key to retry.";
tempkey$ = input$(1)
resume 0

Contact us

QBdirect

If you have not registered

The services on this member site are available only for registered customers.

New member reg.