Accessing Files Programmer's Guide (32650-90885)

216 AppendixA
Pascal/XL Program Examples
Program Example A-2
msgbuf : pac80;
begin {* close_tape_file *}
FCLOSE (file_num, 1, 0); {* close file, rewind and unload tape*}
if ccode = ccl then {* check for error condition *}
begin
msgbuf := 'Can''t close tape file';
PRINT (msgbuf, -21, 0);
print_fserr (file_num);
handle_file_error (file_num, 6);
end;
end; { close_tape_file }
procedure close_disk_file
(
file_num : integer
);
{************************************************************************}
{* PURPOSE: }
{* This routine closes the NEW disk file as PERMANENT disk }
{* file. If an error occurs on the FCLOSE then the user is }
{* given the opportunity to fix the problem and the FCLOSE is }
{* retried. }
{* PARAMETERS: }
{* file_num (input) }
{* - file number of the open disk file }
{************************************************************************}
var
file_closed : boolean;
begin { close_disk_file }
file_closed := false;
repeat
FCLOSE (file_num, 1, 0); { close disk file as a permanent file}
if ccode = ccl then { check for error condition}
handle_fclose_error
else
file_closed := true;
until file_closed;
end; { close_disk_file }
{************************************************************************}
{ MAIN PROGRAM }
{************************************************************************}
begin
open_tape_file (tape_file); { STEP 1 }
open_disk_file (disk_file); { STEP 2 }
print_user_label (tape_file); { STEP 3 }
copy_file_from_tape_to_disk (tape_file, disk_file); { STEP 4