EMS Manual

Retrieving Event Messages Programmatically
EMS Manual426909-005
4-16
Extracting Tokens From the Response (SSGET)
Extracting Tokens From the Response (SSGET)
At the highest level, the GETEVENT response includes only a few basic tokens,
among them the event message itself. To extract these tokens from the response
buffer, use the SSGET procedure. (For a description of SSGET, see the SPI
Programming Manual.)
ZSPI^TKN^RETCODE. The return token is used to report the overall result of the
command processing, as it is for all other subsystem command-response
interfaces. A nonzero value means that a serious error has occurred. A value of
zero indicates that the command completed without errors. However, a warning
might have been issued (for example, an end-of-file warning, as described in
Obtaining an Event Message (GETEVENT) on page 4-12 under
ZEMS^TKN^EOFSTOP).
ZEMS^TKN^EVENT (nonshared). This token contains the event message you
requested by issuing the GETEVENT command message.
ZSPI^TKN^CONTEXT. This token contains the current distributor context, as
described in Obtaining an Event Message (GETEVENT) on page 4-12.
ZEMS^TKN^PASSVAL (nonshared). If the filter executed a PASS statement that
included a pass value (for example, PASS 3), the PASSVAL token contains the
pass value. If the filter executed a simple PASS statement (with no specified
value), this token is not present.
For example, to extract the event message from the response buffer:
spi^error := SSGETTKN(spibuffer,
ZEMS^TKN^EVENT,
emsbuffer, !an integer array
1);
! Handle any error from SPI procedure
IF spi^error <> ZSPI^ERR^OK THEN ...
! Reset buffer length to what you declared for evtbuffer
@evtbuffer := @emsbuffer '+' 1; !skip over length field
spi^error := SSPUTTKN(evtbuffer,
ZSPI^TKN^RESET^BUFFER,
ZEMS^VAL^BUFLEN);
! See if anything wrong with evtbuffer
IF spi^error <> ZSPI^ERR^OK THEN ...
Extracting Tokens From the Event Message (EMSGET)
To extract tokens from an event message, use the EMSGET procedure. For a detailed
description, see Section 15, EMS Procedures
. EMSGET is analogous to SSGET, but
EMSGET retrieves tokens from event messages. SSGET retrieves tokens from
command and response messages.