Accessing Files Programmer's Guide (32650-90885)

204 AppendixA
Pascal/XL Program Examples
3. Close (FCLOSE) the tape file and the disk file (see procedure
close_file).
If a file system intrinsic returns an unsuccessful condition code, procedure
handle_file_error is called to print file information and then abort the program.
Source code listing
Example A-1. Sequential Access
$standard_level 'hp3000'$
$lines 100$
$code_offsets on$
$tables on$
$list_code on$
program open_close_example(input,output);
{***********************************************************************}
{ DECLARATION PART }
{***********************************************************************}
const
ccg = 0; {Condition code warning }
ccl = 1; {Condition code error }
cce = 2; {Condition code successful }
update = 5; {HPFOPEN item value }
save_temp = 2; {HPFOPEN item value }
save_perm = 1; {HPFOPEN item value }
new = 0; {HPFOPEN item value }
permanent = 1; {HPFOPEN item value }
write = 1; {HPFOPEN item value }
type
pac256 = packed array [1..256] of char;
pac80 = packed array [1..80] of char;
status_type = record {HPFOPEN status variable type}
case integer of
0 : (info : shortint;
subsys : shortint);
1 : (all : integer);
end;
var
disk_file : integer;
tape_file : integer;
filename : pac80;
std_list : integer;
std_in : integer;
outbuf : pac80;
function FREAD: shortint; intrinsic; {Read from mag tape file }
procedure HPFOPEN; intrinsic; {Open tape, disk, $STDLIST files }
procedure FCLOSE; intrinsic; {Close tape and disk files }
procedure FWRITE; intrinsic; {Write to disk and $STDLIST files}
procedure PRINTFILEINFO; intrinsic; {If unsuccessful intrinsic call }
procedure QUIT; intrinsic; {If unsuccessful intrinsic call }