Accessing Files Programmer's Guide (32650-90885)

Appendix A 207
Pascal/XL Program Examples
inbuf : pac80;
end_of_file : boolean;
read_length : integer;
begin
end_of_file := false;
repeat
{**In a loop, do a simple sequential read from tape file to ***}
{**disk file. **}
read_length := FREAD (tape_file, inbuf, 80);
if ccode = ccl then
handle_file_error (tape_file, 3)
else
if ccode = ccg then
end_of_file := true
else
begin
FWRITE (std_list, inbuf, read_length, 0);
if ccode <> cce then
handle_file_error (std_list, 4);
FWRITE (disk_file, inbuf, read_length,0);
if ccode <> cce then
handle_file_error (disk_file, 5);
end
until end_of_file;
end; {end procedure }
procedure close_file
(
file_num : integer;
disp : integer
);
{************************************************************************}
{ procedure close_file is a generic file closing procedure that allows }
{ you to specify the final disposition of the file. }
{************************************************************************}
var
msgbuf : pac80;
begin
FCLOSE (file_num, disp, 0);
if ccode = ccl then
handle_file_error (file_num, 6);
end; {end procedure }
{************************************************************************}
{ MAIN PROGRAM }
{************************************************************************}