[comp.sys.ibm.pc] Turbo Pascal file prob

brian@chemo.UUCP (06/20/87)

I am having difficulty with turbo pascal file handling. The following
always yields a run time error, and I can't figure out why!

program junk;

var log:    text;

begin
   assign(log,'z');
   reset(log);
   append(log);
   writeln(log,'hi there big guy!');
   close(log);
end.


this seems to open the file 'z' but always hits a run time error with
the close(log) line. I wrote another program that wrote to a file,
and used the same commands, and it worked fine. Help!

epiwrl!chemo!brian    or...
chemo!brian@wrl.epi.com

davidr@hplsla.UUCP (06/30/87)

This could be the  bug/feature  of the Turbo Pascal append  command I ran into
last year.  I called  Borland, and the comment was that the file you are going
to append to must not only  exist, but  end-of-file  (the point  where it will
begin to append) must be a 1A (a  control-Z)  character.  If the file does not
exist  that you want to append to, then doing a RESET  will  cause a  run-time
error.  However,  if the  file  does  exist  but  does  not  have a  control-Z
terminating character, then the run-time error is likely to occur in trying to
CLOSE the  "non-existing"  file.  (I just tested this quickly, and even though
it was difficult to create a zero length file, when I ran your program on that
file, it aborted on the CLOSE command.)