jbww@ukc.ac.uk (J.B.W.Webber) (10/25/89)
In article <2845@harrier.ukc.ac.uk> mtp@ukc.ac.uk (M.T.Paley) writes: >Hello, > Has anyone ever managed to send a message to a desk accessory in GEM? >It always bombs out whenever I send a message to any but the process that is >sending the message ( the ap_id returned by appl_open() ). > > E.G. > : > ap_wid = appl_find("MYACC "); /* This bit works */ > gets(message); /* Unimportant */ > appl_write(ap_wid,strlen(message),message); /* This crashes */ > : > >However if appl_find is given the name of the current process then this >code works fine. > >It is not the desk accessory that is at fault as it works perfectly with system >messages sent by the AES. > >Anyone tried anything similar at any time? > > Matthew > >Janet: mtp@uk.ac.ukc > phg445@uk.ac.ukc.saturn@uk.ac.ukc O.K. I have both an answer and a question : (hence the posting - I hope the info will be of use to some, I hope that someone can answer my query. The following code I wrote appears to work as expected : It wakes up a desk accessory by sending it an AC_OPEN message. Note : first it uses appl_find to get the handle, then writes a 16 Byte message to it; for the accessory to actually get a chance to do anything appl_yield must be called (Tos 1.4), or event_timer with a delay of zero - note 32 bits : event_timer(0) will crash. (I know !) The format of the message depends on the message, but if the standard event_multi is to process it should contain between 6 and 16 Bytes : i.e. the first 3 ints must be present. If it is longer, then appl_read must be used to process it. My question concerns th 4th int in Mssg (a 1) : for AC_OPEN, this should be "the number of the accessory (on the menu bar)" - how do I establish this ? Is it the same as the acc_handle (also a 1) ? (An accessory only realy needs to check this if it is installing more than one entry on the menu bar.) WORKS : (excuse mixed ints, Bytes) wake_acc() { int acc_handle, res ; int Mssg[8] = { AC_OPEN, handle, 0, 1, 0,0,0,0 } ; acc_handle = appl_find("ANACLOCK"); res = appl_write(acc_handle, 16, Mssg ); evnt_timer(0,0); } Hope this helps people (if I have erred, please say - I have read what I can, but the sheer surprise when something like this works ....) cheers beau webber jbww.@ukc.ac.uk P.S. why is it one knows more of what is happening at the other end of the world, than at the other end of the building ?