Quantcast
Channel: stardot.org.uk
Viewing all articles
Browse latest Browse all 3333

programming • Re: whats wrong with this simple code?

$
0
0
Or you could use an ON ERROR statement to trap the "Out of DATA" error which will inevitably occur. Here's an example lifted directly from something I wrote:

Code:

110 ON ERROR IF ERR=42 GOTO 480 ELSE CLOSE#0:REPORT:PRINT" at line ";ERL:END
ERR is a BASIC pseudo-variable giving the most recent error number, and 42 represents "Out of DATA" (if your User Guide is not to hand and you have not memorised them, you can always create an error deliberately and check ERR immediately afterwards) which is the condition we are expecting and able to handle. The code to do so begins at line 480. If any other error occurred, it must be a real one; so we close all open files (in case the error had something to do with a file access), display the error message and bow out gracefully.

Statistics: Posted by julie_m — Mon Nov 18, 2024 11:57 pm



Viewing all articles
Browse latest Browse all 3333

Trending Articles