SNDRCVF (Send/Receive File)

SNDRCVF Command syntax diagram

 

Purpose

The Send/Receive File (SNDRCVF) command is used by a control language (CL) program to send data to and receive data from a device that is being used interactively by a user. The data is passed between the program in which the SNDRCVF command is used and the display device identified in the command. The data is passed using the display device file that was declared in the program. (A Declare File (DCLF) command included in the source used to compile the program was used to declare the file.) The data for each send/receive operation is passed as one record in a format identified by the RCDFMT parameter of this command (the format is defined in the data description specifications (DDS)). One CL variable is used for each field of the record format to pass the data. The CL variables used (including DDS indicators) are declared implicitly.

Of the record formats specified in the DCLF command, only one can be specified in each SNDRCVF command. If the device file has not been opened, it is opened by this command. The file and record format specified in this command can be overridden by an Override with Display File (OVRDSPF) command if that command is entered before the file is opened. However, care should be taken that the fields in the overriding record format correspond to the CL variables declared in the program.

Restriction: This command is valid only for display files within a CL program. It cannot be used with database files.

 

Optional Parameters

DEV
Specifies the name of the display device to which the CL program's data is sent and from which the user's data is received. A CL variable can be specified on this parameter so that the device name can be changed without changing the command.

*FILE: The data is sent to and received from the device associated with the device file (the device file that was declared in the FILE parameter of the DCLF command). If more than one device name is specified in the device file, *FILE cannot be specified.

device-name: Specify the name of the device or the name of the CL variable that contains the name of the device to which the CL program sends data and from which it receives data. If a CL variable name is used in this parameter, only one SNDRCVF command is needed in the program to receive data from several devices.

RCDFMT
Specifies the name of the record format that is used to pass the data between the CL program and the user. The format contains all the fields in the record. This parameter must be coded with a record format name if there is more than one record format in the device file; *FILE cannot be coded if there is more than one. SNDRCVF ignores the INVITE DDS keyword.

*FILE: Only one record format is in the device file, which is used to send the data to and receive the data from the user.

record-format-name: Specify the name of the record format in which the data is sent to and received from the user. A CL variable name cannot be used here to specify the record format name.

WAIT
Specifies whether the CL program waits to receive the data from the user's device or continues to process the commands that follow this SNDRCVF command. If WAIT(*NO) is specified, the program must issue a WAIT command later in the program to complete the input operation.

Note: A CL variable cannot be coded on this parameter.

*YES: The program waits until the input operation from the device is completed before the next command is processed.

*NO: The program does not wait for the input data; it continues to process commands until a WAIT command is reached later in the program.

Examples for SNDRCVF

Example 1

DCLF   FILE(MENU1)
  *
  *
  *
SNDRCVF

This command sends and receives user data by way of the device file MENU1. Only one record format exists in the file. The device used is specified in the file.

Example 2

DCLF   FILE(SCR)  RCDFMT(REC8)
  *
  *
  *
SNDRCVF   RCDFMT(REC8)

The CL program sends data to a user and receives data for the user who is using the device named in the device file (*FILE is assumed because DEV is not specified). The data is passed in the format specified by REC8 record format in the device file named SCR. The CL program waits for the user data before continuing.

Example 3

DCLF   FILE(DF1)  RCDFMT(REC8)
  *
  *
  *
SNDRCVF   DEV(&DN)  RCDFMT(REC8)  WAIT(*NO)
  *
  *
  *
WAIT   DEV(&DN)

This command sends and receives user data by way of the device file named DF1. Using the record format REC8, the CL program passes data between itself and the user who is at the device named in the variable &DN, but it does not wait for a response to come back. If the program sends and receives data from several devices, the same SNDRCVF command can be used. Only the device specified by &DN for the DEV parameter must be changed. A WAIT command for each device must be issued later in the program to ensure that all the devices respond.

Error messages for SNDRCVF

*ESCAPE Messages

CPF0859
File override caused I/O buffer size to be exceeded.
CPF0861
File &1 in library &2 is not a display file.
CPF0863
Value of binary data too large for decimal CL variable.
CPF0864
End of file detected for file &1 in &2.
CPF0883
*FILE not valid in DEV parameter for file &1.
CPF0886
Record contains a data field that is not valid.
CPF0887
Data available from previous input request.
CPF4101
File &2 in library &3 not found or inline data file missing.
CPF5068
Program device &4 not found in file &2 in library &3.
CPF5070
File &2 in library &3 has no program devices acquired.