Download HP BASIC for OpenVMS User Manual

Transcript
13.6.5 Writing Records
For a file opened with ACCESS WRITE or ACCESS MODIFY, the PUT
statement moves data from the record buffer to a file using the I/O buffer.
PUT statements are valid on RMS sequential, relative, and indexed files. You
cannot use PUT statements on terminal-format files or virtual array files.
Sequential access is valid on RMS sequential, relative, and indexed files. For
sequential, variable, and stream files, a sequential PUT operation adds a
record at the end of the file. For sequential fixed and relative files, PUT writes
records sequentially or randomly depending on the presence of a RECORD
clause. For indexed files, RMS stores records in order of the primary key’s
collating sequence; therefore, you do not need to specify a random or sequential
PUT. Table 13–3 shows the record context after both random and sequential
PUT operations.
Table 13–3 Record Context After a PUT Operation
Record Access
Mode
File
Type
Current
Record
Next Record
Sequential PUT
Sequential
None
End of file
Sequential PUT
Relative
None
Next record
Sequential PUT
Indexed
None
Undefined
Random PUT
Relative
None
Unchanged
After a PUT operation, the current record pointer has no value. However, the
value of the next record pointer changes depending on the file type and the
record access mode used with the PUT operation. In a sequential, stream, or
variable file, records can only be added at the end of the file; therefore, the
next record after PUT is the end of the file. In a relative, sequential, or fixed
file, the next record after a PUT operation is the next logical record.
The following example opens a sequential file with ACCESS APPEND
specified. For sequential files, this is almost identical to ACCESS WRITE.
The only difference is that, with ACCESS APPEND, BASIC positions the file
pointer after the last record in the file when it opens the file for processing. All
subsequent PUT operations append the new record to the end of the existing
file.
File Input and Output 13–19