Article View: comp.sys.atari.st
Article #5242GEM messages --- longer messages
From: Ralf Haacke
Date: Wed, 25 Oct 1989 13:58
Date: Wed, 25 Oct 1989 13:58
73 lines
2820 bytes
2820 bytes
>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?
>
--------------------------------------------------------------------------------
In the first three WORD of a GEM message must be present 'internal message-id',
'GEM-id of the sender' and 'length of the "full" message - 16'.
For your PROGRAM:
int appl_id; /* Application-id */
int msg[100];
:
ap_wid = appl_find("MYACC ");
gets(message);
/* Thas new !!! */
msg[0] = 1024; /* internal message-id */
msg[1] = appl_id; /* I'm sending this message */
msg[2] = strlen(message)-10; /* add 6 for administration-bytes (0..2)
sub 16 for bytes in msg-buffer */
msg[2] = msg[2]<0 ? 0 : msg[2]; /* No negativ numbers !!!!! */
strcpy((char*)&msg[3], message);
/* And now your program */
appl_write(ap_win,msg[2]+16,msg);
evnt_timer (1000,0); /* Wait a moment for the accessory to
receive the message */
:
The ACCESSORY:
int msg[8];
char out[200];
:
evnt_mesag(msg); /* get a message */
if (msg[2] != 0) /* more then 16 Bytes transfered */
{
/* save the first bytes (WORD:3..8) */
memcpy(out, (char*)&msg[3], 10);
/* add the rest of the message */
appl_read(acc_id,msg[2],&out[10]);
/* end the string */
out[10+msg[2]] = '\0';
puts(out);
}
:
I hope this can help you.
Dieter
--------------------------------------------------------------------------------
| Dieter Fiebelkorn | With a rubber duck, :-{ |
| fiebelko@gandalf.irb.informatik.uni-dortmund.de | one's never alone. :^} |
--------------------------------------------------------------------------------
Technical Details
Message-ID:
<1693@laura.UUCP>Path:
arc1-ca.pugleaf.net!utzoo!attcan!utgpu!jarvis.csri.toronto.edu!mailrus!tut.cis.ohio-state.edu!bloom-beacon!eru!luth!sunic!mcsun!unido!laura!exunido!haackeShow Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!attcan!utgpu!jarvis.csri.toronto.edu!mailrus!tut.cis.ohio-state.edu!bloom-beacon!eru!luth!sunic!mcsun!unido!laura!exunido!haacke From: haacke@exunido.uucp (Ralf Haacke) Newsgroups: comp.sys.atari.st Subject: GEM messages --- longer messages Keywords: GEM AES messages Message-ID: <1693@laura.UUCP> Date: 25 Oct 89 13:58:57 GMT Sender: news@laura.UUCP Reply-To: fiebelko@gandalf.irb.informatik.uni-dortmund.de (Dieter Fiebelkorn) Organization: University of Dortmund, W-Germany Lines: 73