GETMESSAGE

From STX Wiki
Jump to navigation Jump to search

GETMESSAGE

This macro retrieves and dispatches messages. If a message handler is installed, the message is forwarded to the handler to perform message processing.

The argument queued controls the processing of messages stored in the secondary queue. This queue is filled with messages which can not be processed at the time. The processing of the secondary queue should be disabled in (sub-) message loops which queue (unknown) messages by calling the macro MSGQUEUE.

If the argument forever equals 0, all messages which were not processed by a handler, are returned. If forever equals 1, all not processed messages are ignored and GETMESSAGE stays active until the application is finished (variable APPMODE<1). Most applications uses the call getmessage 1 1 to implement the main message loop.

The argument nodispatch can be set to 1 to disable message handlers. In this case all messages are returned and must be processed by the caller.

Usage:

GETMESSAGE [ queued forever nodispatch ]

Parameters:
queued
Process messages from secondary queue (0=no, 1=yes; def.=1)
forever
Run while application is active, do not return not-processed (0=no, 1=yes; def.=0)
nodispatch
Disable message dispatching, return all messages (0=no, 1=yes; def.=0)
Result:

The shell variable RESULT is set to the first not processed message ("type name id par") or "* * * *" if application is finished

Examples:

Define a message handler and then process messages until the application is closed.

setmsghandler * * mh
do while $AppMode != 0
        getmessage
end
setmsghandler * *
Notes:

PostMessage

See also

SETMSGHANDLER