Where allowed to run:
|
Parameters Examples Error messages |
The Send/Receive File (SNDRCVF) command is used by a CL procedure 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.
Restrictions: This command is valid only within a CL procedure and only for display files. It cannot be used with database files.
Top |
Keyword | Description | Choices | Notes |
---|---|---|---|
DEV | Display device | Name, *FILE | Optional, Positional 1 |
RCDFMT | Record format | Name, *FILE | Optional, Positional 2 |
OPNID | Open file identifier | Simple name, *NONE | Optional |
WAIT | Wait | *YES, *NO | Optional |
Top |
Specifies the name of the display device that the CL procedure's data is to be sent to and the user's data is to be received from. A CL variable can be specified for this parameter so that the device name can be changed without changing the command.
Top |
Specifies the name of the record format that is to be used to pass the data between the CL procedure 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.
Top |
Specifies the open file identifier that was declared on a preceding Declare File (DCLF) command in the same CL procedure. A CL variable cannot be specified for this parameter value.
Top |
Specifies whether the CL procedure either 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.
Top |
Example 1: Using Display File with One Record Format
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: Using Display File with Multiple Record Formats
DCLF FILE(SCR) RCDFMT(REC8) : SNDRCVF RCDFMT(REC8)
The CL procedure 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 procedure waits for the user data before continuing.
Example 3: Using a CL Variable for Device Name
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 procedure 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 procedure 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 procedure to ensure that all the devices respond.
Example 4: Using Open File Identifier
DCLF FILE(SCREEN1) RCDFMT(REC1 REC2) OPNID(OUTDSP1) DCLF FILE(SCREEN2) RCDFMT(REC3 REC4) OPNID(OUTDSP2) : SNDRCVF DEV(*FILE) RCDFMT(REC2) OPNID(OUTDSP1) WAIT(*YES)
The device file named SCREEN1 is used to send data to the display device named in the same device file and wait for input. The data is presented to the user in the format specified by record format REC2. The SNDRCVF command is associated with device file SCREEN1 because the open file identifier specified on the SNDRCVF command matches the open file identifier specified on the DCLF command for display file SCREEN1.
Top |
*ESCAPE Messages
Top |