[comp.sys.mac.programmer] ResErrProc

jeremyr@cs.qmc.ac.uk (Jeremy Roussak) (08/11/89)

Has anyone any experience of using this?  It seems from IM that if you
put the address of a procedure into it, the procedure will be called
if any call to the resource manager produces an error.  I tried it
using a routine written in LSC that opened a window and tried to write
a message into it.  All that happened was the garbage was written on
the screen and my Mac died.  The routine was declared as 
static pascal void foobar().

Any ideas?

Jeremy Roussak

(working code fragments sent by email would be much appreciated)

jeremyr@cs.qmc.ac.uk (Jeremy Roussak) (08/22/89)

I had only one response to my last posting asking for help on this topic
and he (thanks, Ari) suggested posting the code as well, so here goes:

I am trying to use the ResErrProc global.  IM states that you can put
a routine address into ResErrProc which will be called (by ResError?)
if ResError is about to return a non-zero code.  I use the following code:

pascal void ResourceError()
 {  int error;
    asm { move.w d0, error }	/* error code is in d0 */
    /* code here to open a window and draw some strings into it,
       including the error code.  No access to resources, etc */
    ExitToShell();
 }


main()
 {  ResErrProc = ResourceError;
/* seems immediately to go into ResourceError */
 ...
 }

When resourceError is entered, a5 seems to be garbage.  It opens the 
window, draws garbage on the screen and crashes.  LSC (3.0) is left
complaining "out of memory" when I try to do anything else, and
quitting from LSC and trying to restart it gives me the message
that the project file is already open.

H E L P!!

Jeremy Roussak