Accessing Files Programmer's Guide (32650-90885)
Chapter 5 101
Opening a File
Opening a Device File
Example 5-5. Opening an Unlabeled Magnetic Tape File
procedure open_unlabeled_magnetic_tape_file;
const
formal_designator_option = 2; {defines HPFOPEN
itemnum
2 }
domain_option = 3; {defines HPFOPEN
itemnum
3 }
access_type_option =11; {defines HPFOPEN
itemnum
11 }
density_option =24; {defines HPFOPEN
itemnum
24 }
device_class_option =42; {defines HPFOPEN
itemnum
42 }
type
pac80 = packed array [1..80] of char;
var
tfile_num : integer; {required HPFOPEN
filenum
parameter }
status : integer; {returns info if error/warning occurs}
file_name : pac80; {declares HPFOPEN
itemnum
2 }
permanent : integer; {declares HPFOPEN
itemnum
3 }
update only : integer; {declares HPFOPEN
itemnum
11 }
device_class : pac80 {declares HPFOPEN
itemnum
24 }
density : integer; {declares HPFOPEN
itemnum
42 }
begin
tfile_num :=0;
status :=0;
file_name :='&tapefile&'; {delimiter is "&" }
permanent :=1; {search system file domain }
update_only :=5; {preserves existing data }
density :=1600; {select this tape density }
device_class :='&tape&'; {system-configured device class name }
HPFOPEN (tfile_num, status,
formal_designator_option, file_name, {
formaldesignator option
}
domain_option, permanent, {
domain option
}
access_type_option, update_only {
access type option
}
density_option, density, {
density option
}
device_class_option, device_class {
device class option
}
);
if status <> 0 then handle_file_error (tfile_num, status);
end;
If the HPFOPEN call is successful, a positive integer value is returned in tfile_num, and
status returns a value of zero. The file is now open and can be accessed with file system
intrinsics. If an error or warning condition is encountered by HPFOPEN, status returns a
nonzero value, thus invoking the error-handling procedure handle_file_error.
In appendix A, "HP Pascal/iX Program Examples," Example A-1 uses a similar procedure
to open an unlabeled magnetic tape file. For more information about HPFOPEN parameters,
refer to the MPE/iX Intrinsics Reference Manual.
Opening a labeled magnetic tape file
Example 5-6 is an HP Pascal/iX code segment containing an HPFOPEN intrinsic call that