Accessing Files Programmer's Guide (32650-90885)

228 AppendixA
Pascal/XL Program Examples
Program Example A-5
end_of_file := false;
FLOCK (old_discfile,1);
if ccode = ccl then
handle_file_error (old_discfile, 3);
repeat
{ Read record from disk file, write employee name to $stdlist }
{ and read corresponding record number from $stdin and update }
{ the disk file with the input record and unlock disk file. }
read_length := FREAD (old_discfile, inbuf, 128);
if ccode = ccl then
handle_file_error (old_discfile, 4)
else
if ccode = ccg then
end_of_file := true
else
begin
FWRITE (std_list, inbuf, -20, octal('320'));
if ccode <> cce then
handle_file_error (std_list, 5);
dummy := FREAD (std_in, inbuf[20], 5);
if ccode = ccl then
handle_file_error (std_in, 6)
else
if ccode = ccg then
end_of_file := true;
FUPDATE (old_discfile, inbuf, 128);
if ccode <> cce then
handle_file_error (old_discfile, 7);
end
until end_of_file;
FUNLOCK (old_discfile); { final unlock of disk file }
if ccode <> cce then
handle_file_error (file_num, 2);
end; { end update_file }
procedure close_disk_file
(
file_num : integer;
disp : integer
);
{*************************************************************************}
{procedure close_disk_file is a generic file closing procedure that }
{allows you to specify the final disposition of the file you are closing. }
{*************************************************************************}
var
msgbuf : pac80;
begin
FCLOSE (file_num, disp, 0);
if ccode = ccl then
handle_file_error (file_num, 8);
end; { end close_disk_file }