Accessing Files Programmer's Guide (32650-90885)

Chapter 8 125
Writing to a File
Writing to a Magnetic Tape File
Writing to a Magnetic Tape File
The following discussion pertains to writing data to two different types of magnetic tape
files.
unlabeled magnetic tape files
labeled magnetic tape files
Unless you specifically create and open a labeled magnetic tape file, the file system opens
an unlabeled magnetic tape file when you specify a tape drive using either the
device
name option
or
device class option
of HPFOPEN/FOPEN. For more information about
opening both unlabeled and labeled magnetic tape files, refer to chapter 5, "Opening a
File".
When you are writing records to an unlabeled magnetic tape file, you must take into
consideration characteristics of magnetic tape that do not apply to files on other devices.
For example, if a user program attempts to write over or beyond the physical EOT marker,
the FWRITE intrinsic returns an error condition code (CCL). The actual data is written to
the tape, and a call to FCHECK reveals a file error indicating END-OF-TAPE. All writes to the
tape after the EOT tape marker has been crossed transfer the data successfully, but return
a CCL condition code until the tape crosses the EOT marker again in the reverse direction
(rewind or backspace). For more information about magnetic tape considerations, refer to
chapter 7, "Record Selection and Data Transfer".
Writing records to a labeled tape file differs slightly from writing to an unlabeled tape file.
If the magnetic tape is unlabeled and a user program attempts to write over or beyond the
physical EOT marker, the FWRITE intrinsic returns an error condition code (CCL). The
actual data has been written to the tape, and a call to FCHECK reveals a file error indicating
END-OF-TAPE. All writes to the tape after the EOT tape marker has been crossed transfer
the data successfully, but return a CCL condition code until the tape crosses the EOT
marker again in the reverse direction (rewind or backward).
If the magnetic tape is labeled, a CCL condition code is not returned when the tape passes
the EOT marker. Attempts to write to the tape after the EOT marker is encountered cause
end-of-volume (EOV) labels to be written. A message then is printed on the operator's
console requesting another reel of tape to be mounted.
The following headings provide examples of file system intrinsic calls that illustrate:
writing to an unlabeled magnetic tape file
writing to a labeled magnetic tape file
writing a user-defined file label on a labeled tape file
Writing to an unlabeled magnetic tape file
Example 8-6 is an HP Pascal/iX code segment that writes user-supplied data to the
unlabeled magnetic tape file opened in example 5-5. For information about the HPFOPEN
call that returns the file number in the variable unlabeled_tape_file, refer to example
5-5.