17.07.2013 Views

GWBASIC User's Manual

GWBASIC User's Manual

GWBASIC User's Manual

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

GW-BASIC <strong>User's</strong> Guide<br />

ERR and ERL Variables<br />

Purpose:<br />

To return the error code (ERR) and line number (ERL) associated with an error.<br />

Syntax:<br />

v=ERR<br />

v=ERL<br />

Comments:<br />

The variable ERR contains the error code for the last occurrence of an error. All the error codes<br />

and their definitions are listed in Appendix A of the GW-BASIC <strong>User's</strong> Guide.<br />

The variable ERL contains the line number of the line in which the error was detected.<br />

The ERR and ERL variables are usually used in IF-THEN, or ON ERROR...GOTO, or GOSUB<br />

statements to direct program flow in error trapping.<br />

If the statement that caused the error was a direct mode statement, ERL will contain 65535. To<br />

test if an error occurred in a direct mode statement, use a line of the following form:<br />

IF 65535=ERL THEN ...<br />

Otherwise, use the following:<br />

10 IF ERR=error code THEN...GOSUB 4000<br />

20 IF ERL=line number THEN...GOSUB 4010<br />

Note<br />

If the line number is not on the right side of the relational operator, it cannot be renumbered by<br />

RENUM.<br />

Because ERL and ERR are reserved variables, neither may appear to the left of the equal sign in a<br />

LET (assignment) statement.<br />

file:///C|/Documents%20and%20Settings/Lorenzo/Desktop/GW%20Basic/ERRERL.html28/03/2004 21.29.25

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!