COBOL Manual for TNS and TNS/R Programs

Procedure Division Verbs
HP COBOL Manual for TNS and TNS/R Programs522555-006
9-182
READ for Sequential or Dynamic Access
The PROMPT phrase (often used for the WRITE/READ action common in
requesters) is effective only when the device with which the file is associated is
either a terminal or a process and the open mode of the file is I-O.
When these conditions are met, the PROMPT phrase causes the value of
prompt-item to be sent to the file before the actual read operation begins
(as if a write operation preceded the read operation). The record area is then
cleared to spaces for the length of the prompt-item. Characters being read
from the terminal or process are then copied into the record area.
When the specified conditions are not met, the PROMPT phrase is ignored.
If the file has variable-length records, then the DEPENDING ON data item
does not affect the length of the string written from the prompt-item. To write a
variable-length prompt-item, use reference modification. You can also write
a variable-length prompt-item by using an OCCURS DEPENDING phrase
in the prompt-item, but then you cannot use reference modification on the
prompt-item elsewhere in the program.
°
Inability to establish a position for the read operation
The run-time routines examine the file position indicator at the start of the read
operation. Certain settings of the file position indicator reflect that the read
operation is unable to retrieve any record:
°
If the file position indicator indicates that no valid next record has been
established, the read operation terminates immediately with I-O status
code “46.”
°
If the file position indicator indicates that an optional file is not present, the
run-time routines change the setting of the file position indicator to indicate
that the at-end condition already exists. The read operation then
terminates with I-O status code “10.” Execution then proceeds as
described in the rule for the at-end condition (see the usage condition
Retrieval
).
File-Status Data Item
You can declare a file-status data item for a file in its file-control entry. During each
execution of a READ statement, this file-status data item is assigned a new value
that reflects the outcome of the read operation.