Pathway/iTS SCREEN COBOL Reference Manual (G06.24+, H06.03+, Pathway/iTS 1.0+)

Procedure Division
Compaq NonStop™ Pathway/iTS SCREEN COBOL Reference Manual426750-001
6-61
RECEIVE UNSOLICITED MESSAGE Statement
The following rules apply:
The RECEIVE UNSOLICITED MESSAGE statement completes immediately if the
unsolicited message queue for the SCREEN COBOL program contains a message;
otherwise, the RECEIVE UNSOLICITED MESSAGE statement will wait for the
arrival of an unsolicited message or a timeout, if a timeout was specified.
The execution of the RECEIVE UNSOLICITED MESSAGE is the beginning step
in processing any unsolicited message. The RECEIVE UNSOLICITED MESSAGE
is executed in the following cases:
1. The ESCAPE ON UNSOLICITED MESSAGE clause of an ACCEPT statement
executes due to the arrival of an unsolicited message.
2. A SEND MESSAGE statement is interrupted and its ESCAPE ON
UNSOLICITED MESSAGE clause is executed.
3. You test the PW-UNSOLICITED-MESSAGE-QUEUED special register and
find it equals YES.
4. The SCREEN COBOL program executes RECEIVE UNSOLICITED
MESSAGE and waits for the arrival of an unsolicited message.
For case 4, you might want to include a TIMEOUT clause if there is a possibility
that the SCREEN COBOL program could wait indefinitely for an unsolicited
message to arrive.
Consider the following SCREEN COBOL example with multiple receive codes:
PROCEDURE DIVISION.
UNSOLICITED-MESSAGE-HANDLER.
RECEIVE UNSOLICITED MESSAGE
CODE RC-1 YIELDS R-MSG-1
CODE RC-2 YIELDS R-MSG-2
TIMEOUT MAX-TIME
ON ERROR GOTO ERROR-HANDLER.
PERFORM ONE OF MSG-1-RCD
MSG-2-RCD
DEPENDING ON TERMINATION-STATUS.
ERROR-HANDLER.
IF TERMINATION-STATUS = 1 AND
TERMINATION-SUBSTATUS = 40
PERFORM RCV-TIMED-OUT
ELSE
PERFORM ANALYZE-ERROR.
This code executes as follows:
1. The RECEIVE UNSOLICITED MESSAGE statement waits for the arrival of an
unsolicited message. If the unsolicited message queue for this SCREEN COBOL
program contains a message, the operation completes immediately; otherwise, the
RECEIVE UNSOLICITED MESSAGE statement waits for the arrival of an
unsolicited message or a timeout.