[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Applesoft Basic Question
David Wilson <david@uow.edu.au> wrote:
> Another quick quiz. Why do the Applesoft error codes have the strange
> (in comparison to the regular DOS error codes) values listed?
Since nobody else has answered yet, perhaps I can.
> >Applesoft:
> >0: ?NEXT WITHOUT FOR ERROR
> >16: ?SYNTAX ERROR
> >22: ?RETURN WITHOUT GOSUB ERROR
> >42: ?OUT OF DATA ERROR
> >53: ?ILLEGAL QUANTITY ERROR
> >69: ?OVERFLOW ERROR
> >77: ?OUT OF MEMORY ERROR
> >90: ?UNDEF'D STATEMENT ERROR
> >107: ?BAD SUBSCRIPT ERROR
> >120: ?REDIM'ED ARRAY ERROR
> >133: ?DIVISION BY ZERO ERROR
> >163: ?TYPE MISMATCH ERROR
> >176: ?STRING TOO LONG ERROR
> >191: ?FORMULA TOO COMPLEX ERROR
> >224: ?UNDEF'D FUNCTION ERROR
> >254: ?REENTER (bad response to INPUT; non-fatal error)
> >255: BREAK (^C has been struck)
If you look at each of the error messages, eliminate the initial
question mark, the word "ERROR" and the space preceding it, you will
discover that each error number is the sum of the number of characters
in all the preceding error messages.
In other words, the error number is an index into a large table which
contains each of the error messages packed end to end. It reads
something like this:
NEXT WITHOUT FORSYNTAXRETURN WITHOUT GOSUBOUT OF DATA (etc.)
The last character in each message is marked specially (high bit
opposite state) so the error message printer can locate the end of the
message.
254 and 255 are special cases that are not handled in the same way as
other errors.
A cute trick: if you play around with the ONERR GOTO support mechanisms,
you can generate partial error messages. For example, forcing an error
19 would produce "?TAX ERROR" (maybe the IRS is watching you?), and
error 74 would be "?LOW ERROR" (is that anything like a low bridge?).
--
David Empson
dempson@actrix.gen.nz
Snail mail: P.O. Box 27-103, Wellington, New Zealand