[Coco] BASIC09 error handling schema?

Wayne Campbell asa.rand at gmail.com
Mon Jun 4 01:15:33 EDT 2018


I think I should have included a sample. So here's one.

DIM path:BYTE
DIM er:INTEGER

ON ERROR GOTO 100

OPEN #path, "my file":READ
10 CLOSE #path
END

100 er:=ERR \(* ERR contains the current error code
IF er=216 THEN
CREATE #path, "myFile":UPDATE
GOTO 10
ELSE
PRINT "error num: "; er
ENDIF
END


On Sun, Jun 3, 2018, 10:16 AM James Jones <jejones3141 at gmail.com> wrote:

> BASIC09 still has some unfortunate characteristics for backwards
> compatibility with less-structured BASICs, and one of them is ON ERROR
> GOTO.
>
> Is this a reasonable schema to give error handling some kind of structure?
> (I don't know how BASIC09/RunB handle errors--I'd like to think that it
> sets up an error handler once and for all at the top and just remembers
> where it's been told to go on error (or that it hasn't been told, so it
> does its default action.)
>
>             ON ERROR GOTO <line #>
>            <statement which may cause error>
>             IF FALSE THEN
> <line #>    <code to handle error>
>             ENDIF
>             ON ERROR
>
> --
> Coco mailing list
> Coco at maltedmedia.com
> https://pairlist5.pair.net/mailman/listinfo/coco
>


More information about the Coco mailing list