EMS Manual

Example of Retrieving Event Messages
EMS Manual426909-005
A-37
Using PASS Values
! Read ENDLIST token to pop out of error list
spi^err := EMSGETTKN(spi^buf,
ZSPI^TKN^ENDLIST, , 1 );
IF spi^err <> ZSPI^ERR^OK THEN
CALL DEBUG;
RETURN(warning);
END;
Insert a call to get^warning in the getevent^loop procedure, just before the comment
“Find the event message within the GETEVENT response”:
! Check for EOF warning
IF get^warning THEN
RETURN;
You can use the techniques shown in get^warning whenever you must search an error
list for a certain token.
Using PASS Values
The distributor sends the values on filter PASS statements (called PASS values) to the
application in the GETEVENT command response. PASS values indicate to the
application which filter statement passed the current event message. After you insert
these modifications, the application stops if it receives a PASS value of zero (zero is
chosen arbitrarily) but continues to run when it receives all other PASS values (or no
PASS value).
To search for a PASS value of zero, insert these statements in the getevent^loop
procedure, just before the comment “Find the event message within the GETEVENT
response”:
! Look in GETEVENT response for a PASSVAL of 0
passval := -1;
spi^err := EMSGETTKN(spi^buf, ZEMS^TKN^PASSVAL,
passval, 1, , ZEMS^VAL^SSID);
IF spi^err <> ZSPI^ERR^OK
AND spi^err <> ZSPI^ERR^MISTKN THEN
CALL DEBUG;
This statement sets passval to the PASS value if present or leaves passval at -1.
If you insert this test after the call to displ^event (a few statements beyond the last
insertion), the message passed by the PASS 0 statement is the last event message
displayed at your terminal, because the application stops:
! RETURN after displaying the PASS 0 event message
IF passval = 0 THEN
RETURN;
Finally, insert this declaration in the getevent^loop procedure:
INT passval;