Chris McNeil (04/17/91)
I'm trying to set a global variable (alertnum) from a response procedure in a notification routine. Following is the think C code. Could someone please tell me what I'm doing wrong ( I think I'm not setting up and using A5 properly but I'm not sure) Thanks Chris McNeil ---------------------------------------------------------------------- #define nil 0L struct NMRec myNote[10]; /* declare your NMRec */ OSErr err; /* declare for err handling */ EventRecord myEvent; int alertnum; main() { void notify(); alertnum=0; for(;;){ if (alertnum < 10) { alertnum++; notify("\pthis is a notification"); } } } void notify(string) char *string; { pascal void MyResponse(); EventRecord myEvent; /*Handle ManDoneS; declare a handle for the sound */ myNote[alertnum].qType = nmType; /* queue type -- nmType = 8 */ myNote[alertnum].nmMark = 1; /* get mark in Apple menu */ myNote[alertnum].nmSIcon = nil; /* no flashing Icon */ myNote[alertnum].nmSound =(Handle)-1L;; /* set the sound to be played*/ myNote[alertnum].nmStr = (StringPtr)string; /* alert box */ myNote[alertnum].nmResp = (ProcPtr)MyResponse; /* response procedure */ myNote[alertnum].nmRefCon =(long)CurrentA5; /* I need my A5*/ err = NMInstall ((QElemPtr) &myNote[alertnum]); } pascal void MyResponse (NMRec myNote[10]) { SetUpA5(); CurrentA5=(Ptr)myNote[alertnum].nmRefCon; err = NMRemove ((QElemPtr) &myNote[alertnum]); alertnum--; RestoreA5(); }