Topics

sizeof(ERR)?

Alex Farlie
 

Is it possible to have error numbers over 255?

I was wanting in adapting something to possibly implement some "custom-runtime-errors" for a simple program using ERROR so that they could be trapped, and handled using  ON ERROR style handlers.
~~~~

Richard Russell
 

On Sat, Sep 30, 2017 at 04:26 pm, Alex Farlie wrote:
Is it possible to have error numbers over 255?
No, it's an 8-bit number.  But I can't see why that would be a restriction in practice: values 100 to 179 inclusive are available as user-defined error codes; if you need more you can either use a global variable (e.g. ErrorNumber%), which you set in your error handler, or encode the number in the error string similar to this:

      ERROR 123, "Custom error #" + STR$(myerrorcode%)

Richard.

Alex Farlie
 

On 01/10/2017 10:16, Richard Russell wrote:
On Sat, Sep 30, 2017 at 04:26 pm, Alex Farlie wrote:

Is it possible to have error numbers over 255?

No, it's an 8-bit number.  But I can't see why that would be a restriction in practice: values 100 to 179 inclusive are available as user-defined error codes; if you need more you can either use a global variable (e.g. ErrorNumber%), which you set in your error handler, or encode the number in the error string similar to this:

      ERROR 123, "Custom error #" + STR$(myerrorcode%)
Thanks. I felt it best to check this as the documentation didn't outright say ERROR the first parameter was limited to a range of 0 to 255,  Naturally ERR on a BBC Micro is limited to an 8-bit value.

Thanks for the fast response.

Alex Farlie

Richard Russell
 

On Sun, Oct 1, 2017 at 04:46 am, Alex Farlie wrote:
the documentation didn't outright say ERROR the first parameter was limited to a range of 0 to 255
Confirmation can be found at the 'Interpreter internal variables' page at the Wiki where it states '?418: Current value of ERR'; the use of byte indirection indicating that it's an 8-bit value.  Additionally, ?417 and ?419 are documented there (WIDTH and the *FLOAT/*HEX/*LOWERCASE/OPT flags respectively) leaving no room for manoeuvre!

Richard.