$msgid

Return the identifier for a message received from postmessage.

$msgid

Example: putmess " message id =%%$msgid"

Return Values

Values returned in $msgid
Value Meaning
"" Empty string (""), if the asynchronous event was not sent by postmessage; $result indicates the source of the message.
>0 Message identifier, if the receiveMessage trigger was activated by a postmessage statement; $result is "message".

Use

Allowed only in the receiveMessage trigger of components.

Allowed in all component types except self-contained Report and Services.

Message Handling

The following example shows the receiveMessage trigger for an application. The example assumes that MSG_HANDLER is an instance of a service which contains operations for processing asynchronous messages. It also assumes that MSG_HANDLER has already been created (probably in the apStart trigger as the application started).

trigger receiveMessage

if ( $result = "message" )
   putmess "%%$msgdst received from %%$msgsrc" 
   putmess " message id =%%$msgid"
   putmess " message text=%%$msgdata"
   
   if ( $msgid != "Ack")
      postmessage $msgsrc, "Ack", "Acknowledging message %%$msgid" 
   else
      if ( $msgid = "A" ) activate "MSG_HANDLER".A ($msgdata)
      if ( $msgid = "B" ) activate "MSG_HANDLER".B ($msgdata)
      ...
   endif
else
  
  if ( $result = "Close" ) activate "MSG_HANDLER".CLOSE
  if ( $result = "Timeout" ) activate "MSG_HANDLER".TIMEOUT
  else
     putmess "%%$instancename received unexpected async message: %%$result"
endif
end; receiveMessage

Related Topics