EMS Manual
Example of Retrieving Event Messages
EMS Manual—426909-005
A-17
TACL Source File
== Save the original command
#SETBYTES sav^buf spi^buf
== Begin loop that gets and displays event messages
[#LOOP |WHILE| -1 |DO|
== Send GETEVENT command message to the distributor.
#APPENDV distr_request spi^buf
#EXTRACTV distr_reply spi^buf
[#IF distr_error |THEN|
*** [distr_error] sending GETEVENT]
== Protect against a longer buffer in the distributor
#SET spi^buf:z^BUFLEN zems^val^BUFLEN
#SET spi^err [#SSPUT spi^buf ZSPI^TKN^RESET^BUFFER
ZEMS^VAL^BUFLEN]
[#IF spi^err |THEN|
*** [spi^err] on #SSPUT of RESET^BUFFER]
== Process GETEVENT response message
#SETMANY spi^err _{count} ems^err &
, [#SSGET /INDEX 1/ spi^buf ZSPI^TKN^RETCODE]
[#IF spi^err |THEN|
*** [spi^err] on #SSGET of RETCODE]
[#IF ems^err |THEN|
*** [ems^err] RETCODE on GETEVENT command]
== Get the offset of the event-message token
#SETMANY spi^err event_offset &
, [#SSGET /INDEX 1/ spi^buf ZSPI^TKN^OFFSET &
[ZEMS^TKN^EVENT]]
[#IF spi^err |THEN|
*** [spi^err] on #SSGET of OFFSET of EVENT]
== Move past the length part (variable length token)
#SET event_offset [#COMPUTE event_offset + 2
- [#VARIABLEINFO/OFFSET/event^buf:z^filler]]
#SETBYTES event^buf &
spi^buf:z^filler([event_offset]:[#COMPUTE
[spi^buf:z^occurs] - 1])
== Decide if event deserves emphasis as critical
#SETMANY spi^err _{count} emphasis &
, [#EMSGET event^buf ZEMS^TKN^EMPHASIS]
[#IF spi^err |THEN|
*** [spi^err] on #EMSGET of EMPHASIS]
== Call procedure that displays the event
displ^event event^buf
== Move context token from reply into copy of
== original command
#SETMANY spi^err , [#SSMOVE /SINDEX 1, DINDEX 1/
spi^buf == Source
sav^buf == Destination