Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!cs.utexas.edu!uunet!mcsun!sunic!tut!ra!chyde!ts
From: ts@chyde.uwasa.fi (Timo Salmi LASK)
Newsgroups: comp.lang.pascal
Subject: Re: writing a disk file to a full disk
Message-ID: <803@chyde.uwasa.fi>
Date: 29 Sep 89 05:56:14 GMT
References: <8909281232.aa13997@BONNIE.ICS.UCI.EDU>
Reply-To: ts@chyde.uwasa.fi (Timo Salmi LASK)
Organization: U of Vaasa, Finland
Lines: 33

In article <8909281232.aa13997@BONNIE.ICS.UCI.EDU> jduarte@BONNIE.ICS.UCI.EDU writes:
>has nothing to do with my homework !!!
>   Is there any easy way in TP 5.0 to tell whether a disk file is CLOSED
>or OPEN...I mean, suppose that I write ASCII characters to a disk file and
>then the disk becomes full...I can check for an IO error using the IOresult

A very good question! I shall have to look more fully if I can come
up with something positive.  In the meanwhile there is one little
trick, which does not solve the problem, but which is good practice
anyway.  You say that you test the IOResult.  One is well adviced to
do this *also* after each close statement, because there are rare
cases of a near full disk, which may otherwise cause problems.  There
is also another small trick.  I do not know if you have used it in
your program.  That is turning the io-checking back on *immediately*
after each write.  The structure then is like this:
   {$I-}
   writeln (f, 'My message on homework has been obviously heeded to :-)');
   {$I+}
   if IOResult <> 0 then begin ... end;
   {$I-}
   writeln (f, 'If it is impractical, the authorities will go for it');
   {$I+}
   if IOResult <> 0 then begin ... end;
You you find it irksome doing this repetitively (I do) then make a
procedure that performs a single write with IOResult checking. But
what is really interesting is your question about testing for an
open file.  I do not recall seeing it done, but it certainly would
be a useful function to have.

...................................................................
Prof. Timo Salmi                                (Site 128.214.12.3)
School of Business Studies, University of Vaasa, SF-65101, Finland
Internet: ts@chyde.uwasa.fi Funet: vakk::salmi Bitnet: salmi@finfun