EMS Manual
Retrieving Event Messages Programmatically
EMS Manual—426909-005
4-17
Extracting Tokens From the Event Message
(EMSGET)
The tokens you choose to extract depend on your application. For example, to get the
value of the event number token and get the subject token from an event message:
! Retrieve the event number from the event message
spi^error := EMSGETTKN(emsbuffer,
ZEMS^TKN^EVENT^NUMBER,
event^number);
! Handle any error from SPI procedure
IF spi^error <> ZSPI^ERR^OK THEN ...
! Find the first subject token in the event message
spi^error := EMSGETTKN(emsbuffer,
ZEMS^TKN^SUBJECT,
subject^token,
1,
subject^index,
subject^ssid);
! Handle any error from SPI procedure
IF spi^error <> ZSPI^ERR^OK THEN ...
! Get the length of the subject to check against the
! length you declared to receive it
spi^error := EMSGETTKN(emsbuffer,
ZSPI^TKN^LEN,
subject^token,
subject^index,
subject^length,
subject^ssid);
! Handle any error from SPI procedure
IF spi^error <> ZSPI^ERR^OK THEN ...
IF subject^length > declared^size^for^subject^value THEN
! Cannot ssget this subject value
else
BEGIN
spi^error := EMSGETTKN(emsbuffer,
subject^token,
subject^value,
subject^index,
,
subject^ssid);
! Handle any error from SPI procedure
IF spi^error <> ZSPI^ERR^OK THEN ...
END;
! Now, subject^value contains the value of the subject.