RECWAIT Statement
Receives data from a communicating program. If data is not available, RECWAIT waits indefinitely, or for a specified timeout period, for data to be received.
Syntax
RECWAIT data FROM session{,reference} {USING function{,qualifier}} {TIMEOUT minutes} {SETTING error} [THEN statement(s) | ELSE statement(s)]
Syntax Elements
data is the name of a variable to which data received is assigned.
session is a variable defining the session, established by an ACCEPT or CONNECT statement, from which data is to be received.
reference is a variable to which a numeric reference for the data is assigned.
function is a variable to which any further numeric reference received is assigned.
qualifier is a variable to which any string qualifier received is assigned.
minutes is an expression that evaluates to a timeout value in minutes. The ELSE clause is executed and error 4225 is returned if data is not received within this time. If the TIMEOUT clause is omitted, it waits indefinitely.
error is a variable that is assigned an error code number according to any errors detected if the ELSE clause is taken. If the ELSE clause is not taken, the value of error is set to 0. The error codes and corresponding messages are given in File I/O and IPC Error Codes.
statement(s) is either a THEN or an ELSE clause (or both). A statement must be included. The THEN clause is executed if data is received without error within the timeout period. The ELSE clause is executed in the case of an error condition or if data is not received within the timeout period.
Operation
The RECWAIT statement causes the program to halt until data is received from the program identified by session. When data is received and assigned to variable data, the THEN clause is taken. The ELSE clause is executed only in the case of an error condition. If data is not available, the program waits for input.
Example
012 RECWAIT INPT FROM S TIMEOUT 1 SETTING
ECODE ELSE GOTO 72