RECEIVE Statement
Receives data sent by a communicating program. If data is not available, the ELSE clause or the next statement in the program is executed.
Syntax
RECEIVE data FROM session{,reference} {USING function{,qualifier}} {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 a 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.
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 a sequence of one or more valid DataBasic statements, either separated by semicolons or contained on separate lines and followed by an END statement.
Operation
The RECEIVE statement receives any data that has been sent by the program identified by session. If data has been sent and is received, the THEN clause is taken. If no data has been sent and none received, the ELSE clause is taken. If there is no ELSE clause, the next statement is the default error handling statement.
The RECEIVE statement does not wait for data to be sent. It only receives data that has already been sent and branches to the ELSE clause if no data is present to be received. (Compare with the RECWAIT statement.)
Example
012 RECEIVE INPT FROM S SETTING ECODE
ELSE GOTO 99