BBC BASIC for Windows
General >> Suggestion Box >> Increase the ERR internal value from 8 bits to 32
http://bb4w.conforums.com/index.cgi?board=suggestions&action=display&num=1381323924

Increase the ERR internal value from 8 bits to 32
Post by Michael Hutton on Nov 18th, 2010, 05:56am

?418
Current value of ERR

If this could be increased to a 32 bit number it would enable the setting of an error code compatible with windows error codes.

For instance, being able to pass windows or DirectX error codes to the error handler.

eg
Code:
      SYS D3DXCreateSprite%, pDevice%, ^ISprite% TO R%
      IF R% THEN ERROR 100,"Can't Create Sprite Object"
 


would become

Code:
      SYS D3DXCreateSprite%, pDevice%, ^ISprite% TO R%
      IF R% THEN ERROR R%,"Can't Create Sprite Object"
 


and the error code could query the ERR value for the error generate.

Michael
Re: Increase the ERR internal value from 8 bits to
Post by Michael Hutton on Nov 18th, 2010, 06:10am

..but then I suppose a simple

Code:
IF R% PROC_ERROR(R%,"Error stirng")
 


Is just as good.

Ignore this one.

Michael
Re: Increase the ERR internal value from 8 bits to
Post by admin on Nov 18th, 2010, 08:25am

on Nov 18th, 2010, 05:56am, Michael Hutton wrote:
If ERR could be increased to a 32 bit number it would enable the setting of an error code compatible with windows error codes.

Look here and you'll see why this isn't possible:

http://bb4w.wikispaces.com/Interpreter+internal+variables

The addresses of the interpreter's 'internal variables' must remain fixed 'for ever' because many programs access them directly. ERR is ?418 and is immediately followed by the float/lowercase/opt setting at ?419 so there's no room to increase its size.

You could simply store the Windows error code in a global variable and access that in your ON ERROR handler:
Code:

      ON ERROR PROCerror(WinErr%, ERR, REPORT$) QUIT
...
      SYS D3DXCreateSprite%, pDevice%, ^ISprite% TO WinErr%
      IF WinErr% THEN ERROR 100,"Can't Create Sprite Object" 

Richard.