Accessing Files Programmer's Guide (32650-90885)

Appendix A 209
Pascal/XL Program Examples
Program Example A-2
allow the user to specify an alternative file name if, during an FCLOSE call, the file
system determines that a duplicate permanent disk file exists (see procedure
handle_fclose_error).
print file information (PRINTFILEINFO) before aborting (QUIT) the program (see
procedure handle_file_error).
Using these four error procedures, the program individually tailors error-handling
routines to meet different intrinsic needs.
Source code listing
Example A-2. Accessing a Magnetic Tape File
$standard_level 'os_features'$
$os 'mpe xl'$
$code_offsets on$
$tables on$
$list_code on$
program open_and_read_a_labeled_tape (input, output);
{************************************************************************}
{* DECLARATION PART *}
{************************************************************************}
const
ccg = 0; {* condition code "greater than *}
ccl = 1; {* condition code "less than" *}
cce = 2; {* condition code "equal" *}
type
pac80 = packed array [1..80] of char;
status_type = record
case integer of
0 : (info : shortint;
subsys : shortint);
1 : (all : integer);
end;
var
tape_file : integer; {* file number for tape file *}
disk_file : integer; {* file number for disk file *}
function FREAD : shortint; intrinsic;
function READ : shortint; intrinsic;
procedure HPFOPEN; intrinsic;
procedure FCHECK; intrinsic;
procedure FCLOSE; intrinsic;
procedure FWRITE; intrinsic;
procedure PRINT; intrinsic;
procedure PRINTFILEINFO; intrinsic;
procedure QUIT; intrinsic;
procedure CAUSEBREAK; intrinsic;