Previous Topic: WRITE TERMINAL (DC/UCF)Next Topic: Logical-Record Clauses (WHERE and ON)


WRITE THEN READ TERMINAL (DC/UCF)

The WRITE THEN READ TERMINAL statement requests a transfer of data from program variable storage to the terminal buffer and, when the terminal operator has completed entering data, a transfer of that data back to program variable storage.

Syntax
►►─── WRITE ─┬────────┬─ READ TERMIMAL ─┬──────────┬──────────────────────────►
             └─ THEN ─┘                 ├─ WAIT ◄ ─┤
                                        └─ NOWAIT ─┘

 ►─┬─────────────────────────────┬────────────────────────────────────────────►
   ├─┬─ NEWPAGE ─┬───────────────┤
   │ └─ ERASE ───┘               │
   └─┬─ EAU ───────────────────┬─┘
     └─ ERASE ALL UNPROTECTED ─┘

 ►─┬────────────────────────────────────────────────┬─────────────────────────►
   ├─ MODIFIED ─┬─ FROM POSITION (screen-position) ─┘
   └─ BUFFER ───┘

 ►─── FROM (output-data-location) ─┬─ TO (end-output-data-location) ─┬────────►
                                   └─ LENGTH (output-data-length) ───┘

 ►─── INTO (input-data-location) ─┬─ TO (end-input-data-location) ───────┬────►
                                  └─ MAX LENGTH (input-data-max-length) ─┘

 ►─┬─────────────────────────────────────────────────┬─ ; ────────────────────►◄
   └─ RETURN LENGTH INTO (input-data-actual-length) ─┘
Parameters
WAIT/NOWAIT

Indicates whether the I/O operation is to be synchronous or asynchronous.

WAIT

Specifies that the I/O operation will be synchronous; the issuing task will automatically relinquish control to the system and must wait for completion of the I/O operation before processing can continue. WAIT is the default.

NOWAIT

Specifies that the I/O operation will be asynchronous; the issuing task will continue executing.

Note: If NOWAIT is specified, the program must issue a CHECK TERMINAL request (described earlier in this chapter) before performing any other I/O operation.

NEWPAGE/EAU

Specifies the mechanism to be used with the write operation:

NEWPAGE

Activates the page-eject (SYSINOUT devices) or erase-write (3270-type devices) mechanism to erase the contents of a screen. If NEWPAGE is not specified, the WRITE TERMINAL request will write over rather than erase data displayed on the terminal. The keywords NEWPAGE and ERASE are synonymous.

EAU

Activates (for 3270-type devices only) the erase-all-unprotected mechanism. Following a WRITE TERMINAL EAU function, only protected fields remain on the terminal. If EAU is specified, the FROM clause (described below) need not be specified.

MODIFIED/BUFFER

Transfers (for 3270-type devices only) data to the application program without requiring the terminal operator to signal completion of data entry.

MODIFIED

Reads all modified fields in the terminal buffer into program variable storage.

BUFFER

Executes a READ BUFFER command that reads the entire contents of the terminal buffer into the program variable storage.

FROM POSITION (screen-position)

Defines the buffer address (screen position) at which the read will start. Screen-position is either the symbolic name of a user-defined FIXED BINARY(31) field or the address itself enclosed in quotation marks.

FROM (output-data-location)

Specifies the program variable-storage entry of the output data stream. Output-data-location is the symbolic name of a user-defined field. The length of the output data stream is determined by one of the following specifications:

TO (end-output-data-location)

Indicates the end of the output data stream and is specified following the last data-item entry in output-data-location. End-output-data-location is the symbolic name of either a user-defined dummy byte field or a field that contains a data item not associated with the output data stream.

LENGTH (output-data-length)

Defines the length, in bytes, of the output data stream. Output-data-length is either the symbolic name of a user-defined field that contains the length of the data stream, or the length itself expressed as a numeric constant.

INTO (input-data-location)

Specifies the program variable-storage entry of the data area reserved for the input data stream. Input-data-location is the symbolic name of a user-defined field. The length of the input data stream is determined by one of the following specifications:

TO (end-input-data-location)

Indicates the end of the data area reserved for the input data stream and is specified following the last data-item entry in input-data-location. End-input-data-location is the symbolic name of either a user-defined dummy byte field or a field that contains a data item not associated with the data area reserved for the input data stream.

MAX LENGTH (input-data-max-length)

Defines the length, in bytes, of the data area reserved for the input data stream. Input-data-max-length is either the symbolic name of a user-defined field that contains the length of the data stream, or the length itself expressed as a numeric constant.

If the input data stream is larger than the data area reserved in program variable storage, the system truncates the data stream to fit the available space.

RETURN LENGTH INTO (input-data-actual-length)

Indicates the location to which the system will return the actual length of the input data stream. Input-data-actual-length is the symbolic name of a user-defined field. If the data stream has been truncated, input-data-actual-length contains the original length before truncation.

Example

The following statement illustrates a basic mode request to write data from the program (OUTPUT_LINE) to the terminal, read the data from the terminal to the specified location (INPUT_LINE) in the program, and return the actual length of the input data stream (LINE_LENGTH) to variable storage:

WRITE THEN READ TERMINAL
  WAIT
  FROM (OUTPUT_LINE) TO (END_INPUT_LINE)
  INTO (INPUT_LINE) MAX LENGTH (80)
  RETURN LENGTH INTO (LINE_LENGTH);
Status Codes

Upon completion of the WRITE THEN READ TERMINAL function, the ERROR_STATUS field in the IDMS DC communications block indicates the outcome of the operation:

0000

The request has been serviced successfully.

4519

The input area specified for the return of data is too small; the returned data has been truncated to fit the available space.

4525

The output operation has been interrupted; the terminal operator has pressed ATTENTION or BREAK.

4526

A logical error (for Example, an invalid control character) has been encountered in the output data stream.

4527

A permanent I/O error has occurred.

4528

The dial-up line for the terminal has been disconnected.

4531

The terminal request block (TRB) contains an invalid field, indicating a possible error in the program's parameters.

4532

The derived length of the specified I/O data area is zero or negative.

4535

Storage for the input buffer cannot be acquired because the specified program variable-storage entry has been allocated.

4538

The specified program variable-storage entry has not been allocated and the GET STORAGE option has not been specified.

4539

The terminal device associated with the issuing task is out of service.