[comp.sys.atari.st] AES Messages: Sending messages to yourself problem.

achowe@tiger.waterloo.edu (CrackerJack) (04/25/89)

I wish to thank everyone for the answers to my first question about
strings. However I'm still having trouble sending messages to myself.
Below is an example test case that does NOT work. Could someone tell 
me why I don't receive anything.

--->8---

#include <sys\gemdefs.h>

int ApplHandle;
int Dummy;
int Event;
int Msg[8];


void SendMsg( code )
    int code;
{
    int msg[3];

    printf( "Sending message %d\n", code );
    /* set message code. note that this value should not be equal to any of
       the standard GEM messages ( >31 ). */
    msg[0] = code;
    msg[1] = ApplHandle;
    /* Number of bytes extra to read after initial 16 byte message. */
    msg[2] = 0;
	if( appl_write( ApplHandle, 6, msg ) == 0 )
		printf( "appl_write failed\n" );
}


void ChkMsg()
{
    printf( "Message %d received\n", Msg[ 0 ] );
}


void main()
{
    ApplHandle = appl_init();

    SendMsg( 100 );

    for(;;){
        Event = evnt_multi( MU_KEYBD | MU_BUTTON | MU_MESAG,
                            1, 0x3, 1,
                            0, 0, 0, 0, 0,
                            0, 0, 0, 0, 0,
                            Msg, 0, 0,
                            &Dummy, &Dummy, &Dummy, &Dummy, &Dummy, &Dummy );

		/* exit on left mouse button press */
        if( Event & MU_BUTTON ) break;

		/* send a message on a keypress */
        if( Event & MU_KEYBD ) SendMsg( 101 );

		/* see what has arrived for us */
        if( Event & MU_MESAG ) ChkMsg();
    }

    appl_exit();
}
   achowe@tiger.waterloo.edu      |  "Murdered by pirates is good."
 __                    _          |    - The Princess Bride (movie)
/   _  _  _ |/ _  _    | _  _ |/  |
\__| `<_\<_ |\|= | ` \_/<_\<_ |\  |                        disclaimer...