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
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.
Example 8-6. Writing to an Unlabeled Magnetic Tape File
.
.
.
var
control_code : 0..65535; {Declare FWRITE parm. }
record_length: shortint; {Declare FWRITE parm }
file_record : record_type; {Record to be written to file;}
{record_type is 256-byte }
{fixed-length record. }
.
.
.
record_length:= -256; {Number of bytes in record. }
control_code := 0; {Default specified }
FWRITE ( unlabeled_tape_file, {HPFOPEN returned file number.}
file_record {Record to be passed }
record_length {Size of file_record. }
control_code {Required, but ignored. }
);
if ccode = CCL then {check FWRITE condition code }
handle_file_error (labeled_tape_file);
.
.
.
If the FWRITE intrinsic encounters an error condition (CCL), an
error-handling procedure, handle_file_error, is invoked.
FWRITE returns a CCG condition code if the EOF is reached. For details
concerning FWRITE intrinsic parameters, refer to the MPE/iX
Intrinsics Reference Manual.
Example 8-7 is an HP Pascal/iX code segment that writes user-supplied
data to the labeled magnetic tape file opened in Example 5-6. For
information about the HPFOPEN call that returns the file number in
the variable labeled_tape_file, refer to example 5-6.
Example 8-7. Writing to a Labeled Magnetic Tape File
.
.
.
var
control_code : 0..65535; {Declare FWRITE parm. }
record_length: shortint; {Declare FWRITE parm }
file_record : record_type; {Record to be written to file;}
{record_type is 256-byte }
{fixed-length record. }
.
.
.
record_length:= -256; {Number of bytes in record. }
control_code := 0; {Default specified }
FWRITE ( labeled_tape_file, {HPFOPEN returned file number.}
file_record {Record to be passed }
record_length {Size of file_record. }
control_code {Required, but ignored. }
);
if ccode = CCL then {check FWRITE condition code }
handle_file_error (labeled_tape_file);
.
.
.
If the FWRITE intrinsic encounters an error condition (CCL), an error
handling procedure handle_file_error is invoked. FWRITE
returns a CCG condition code if the EOF is reached. For more information about
FWRITE intrinsic parameters, refer to the MPE/iX Intrinsics
Reference Manual. For more information about opening
files, refer to chapter 5, "Opening a File".