[Coco] Error codes on SECB

Robert Gault robert.gault at worldnet.att.net
Sat Nov 18 09:15:25 EST 2006


William Astle wrote:

>snip>
> Also, removing the ONERR yields the expected ?NE ERROR IN 20 message. 
> The upshot of all this is that the handler must be running as there is 
> no code path that would abort that process once it starts. A little 
> examination of the code brought me to the following discovery:
> 
> LOAD sets the DEVNUM value to 1 greater than the number of the reserved 
> files for Disk Basic. It does this *BEFORE* it even attempts to open the 
> file. Unfortunately, it does not get reset to 0 before the NE error is 
> thrown and the ONERR handling code does not reset anything when it fires 
> the handler. In MOST cases, this is the correct result. In the case of 
> LOAD, it isn't.

Very good analysis! But to be fair to Basic, the device number is reset 
by the normal error routine as you have shown, which may be why LOAD 
does not reset it. The question might be (when patching Disk Basic) do 
you want ONERR GOTO to reset the device number to 0? Seems to me that 
the ONERR routine can't predict what action you want taken and therefore 
(one could argue) it should not reset variables such as device number.

This is another good example of the troubles you can get into by 
expecting variables to be set to default (or any other) values. If an 
action is critical, don't take it before explicitly setting important 
variables. In this case, device number was expected to be Screen where 
it could be Printer, Cassette, Screen, or one of many Disk values.

The above does not apply just to writing computer programs, as any 
married couple will tell you who have used the toilet facilities at 
night without turning on the lights. :)



More information about the Coco mailing list