lowey@sask.UUCP (Kevin Lowey) (10/28/87)
Hi,
I've discovered a bug in Turbo Pascal version 3.01a (PC-DOS). This
version has a function called APPEND which is used to open a file
at the end of the file, so that you can append information to the
end.
In version 3.01a of Turbo Pascal, if you try to append to a file
of length 0 (an empty file), when Turbo tries to write the first
buffer to the file (either with the CLOSE command or a lot of
write/writeln commands) you get IO error F0, Disk Write Error.
The following program demonstrates this problem:
======================================================
program bug;
{Demonstates a bug in Turbo Pascal version 3.01 }
{appending to a null file creates an error message }
var fil:text;
begin
{create file of length 0}
assign (fil,'test.fil');
rewrite (fil);
close (fil);
{ append to the file }
append (fil);
write (fil,'Testing, 1,2,3');
close (fil); {<<< IO error F0, "Disk Write Error", occurs here }
end.
===================================================================
The following program fixes this problem:
===================================================================
program fix;
{Demonstates fix to bug in Turbo Pascal version 3.01 }
{appending to a null file creates an error message }
var fil:text;
procedure myappend ( var fil:text);
begin
reset (fil);
if EOF(fil) then
rewrite(fil)
else
append (fil);
end;
begin
{create file of length 0}
assign (fil,'test.fil');
rewrite (fil);
close (fil);
{ append to the file }
myappend (fil);
write (fil,'Testing, 1,2,3');
close (fil);
end.
========================================================
______________________________________________________________________________
| Kevin Lowey |The above is the personal opinion of Kevin |
| University of Saskatchewan |Lowey. It does not reflect the position of|
| Computing Services |the University of Saskatchewan in any way. |
| SaskTel: (306) 966-4826 | |
| Bitnet:LOWEY@SASK. (preferred) |I am in no way affiliated with any of the |
| UUCP: ihnp4!sask!lowey.uucp |above mentioned companies other than U of S|
|________________________________|___________________________________________|