The FREADLABEL intrinsic is used
to read a user-defined label located on a labeled magnetic tape file or a
labeled disk file. To read a user-defined header label, the FREADLABEL
intrinsic must be called before the first FREAD is issued for the file.
Execution of the first FREAD causes MPE/iX to skip past any unread user-defined
header labels.
Example 9-5 is an HP Pascal/iX code segment that reads a user label located in
the user-defined label portion of data_file, a labeled magnetic tape file. The
label is printed to `STDLIST (identified by list_file) using the FWRITE
intrinsic. Assume that both data_file and list_file have been opened elsewhere
with calls to HPFOPEN/FOPEN.
Example 9-5. Reading a User Label from a Labeled Magnetic Tape File
procedure read_user_label;
var
label : packed array [1..80] of char; {holds label from file }
length : shortint; {length of label }
control_code : 0..65535; {required by FWRITE }
begin
length := 40 {required ANSI label size}
control_code := 0 {set to default }
FREADLABEL ( data_file, {file number of tape file}
label, {returns label }
length {# of halfwords to read}
);
if ccode <> cce then handle_file_error (data_file);
FWRITE ( list_file, {output to $STDLIST }
label, {label read by FREADLABEL }
length, {length of label }
control_code {default condition }
);
if ccode <> cce then handle_file_error (list_file);
end; {end read_user_label }
|
If an error is encountered by either FREADLABEL or FWRITE, procedure
handle_file_error is invoked. For more information about FREADLABEL intrinsic
parameters, refer to the MPE/iX Intrinsics Reference Manual (32650-90028). For
more information about the FWRITE intrinsic, refer to chapter 8, "Writing to a
File". In appendix A, "HP Pascal/iX Program Examples", example A-2 uses a
similar procedure to read a user label from a labeled magnetic tape file.