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 }
for counter := 1 to 80 do {Loop to fill array with }
user_label [counter] := ' '; {ASCII blanks. }
user_label := 'tape01 user header label no. 1';
{Overwrite first 30 bytes with label name}
FWRITELABEL (labeled_tape_file, {Required parameter }
user_label, {Required parameter }
label_length {Optional parameter }
);
if ccode = CCL or CCG then {check FWRITELABEL condition code}
handle_file_error (labeled_tape_file);
.
.
.
If ccode indicates that the FWRITELABEL intrinsic encountered
an error condition (either CCL or CCG), an error handling procedure
handle_file_error is invoked. For more information about
FWRITELABEL intrinsic parameters, refer to the MPE/iX Intrinsics
Reference Manual. For more information about opening files, refer to
chapter 5, "Opening a File".