Accessing Files Programmer's Guide (32650-90885)

Chapter 8 127
Writing to a File
Writing a File Label to a Labeled Tape File
record_length {Size of file_record. }
control_code {Required, but ignored. }
);
if ccode = CCL {check FWRITE condition code }
then 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".
Writing a File Label to a Labeled Tape File
User-defined labels are used to further identify files and may be used in addition to the
ANSI-standard labels. User-defined labels are written on files with the FWRITELABEL
intrinsic instead of with the HPFOPEN/FOPEN intrinsic, as is the case for writing
ANSI-standard labels.
User-defined labels for labeled tape files differ slightly from user-defined labels for disk
files, in that user-defined labels for tape files must be 80 bytes (40 half-words) in length.
The tape label information need not occupy all 80 bytes, however, and you can set unused
portions of the space equal to blanks.
In order to write a user-defined header label, the FWRITELABEL intrinsic must be called
before the first FWRITE to the file. MPE/iX does, however, write user-defined trailer labels if
FWRITELABEL is called after the first FWRITE.
NOTE
User-defined labels may not be written on unlabeled magnetic tape files.
Example 8-8 is an HP Pascal/iX code segment that writes a user-label 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-8. Writing a User-Label to a Labeled Magnetic Tape File.
.
.
.
var
counter : integer; {Initialize counter }
label_length : shortint; {FWRITELABEL
length
parm }
user_label : packed array [1..80] of char;
.
.
.
label_length := 40; {40 half-words required length }