[comp.lang.pascal] TP BlockWrite problem?

NORM%IONAACAD.BITNET@tecmtyvm.mty.itesm.mx ( Norman Walsh) (02/16/91)

Has anyone ever had any difficulties with the builtin BlockWrite
function?  Occasionally, Blockwrite fails.  I have been tentative
about posting this question because I can't believe that the problem
is in Blockwrite.  What has lead me to post it is that the problem
has now occured twice.  In two different programs written by
different developers that do entirely different things.

In both cases the block write indicates that 0 bytes where written
when there is no reason that I can think of for the write to fail.
There is certainly enough disk space, it's in a small loop, and
the file has been written to several times before (i.e. it isn't the
first time through the loop that fails).

Leads: -It seems to happen on the last write to the file (the last
        block).
       -It seems to happen only when there is a small amount of disk
        space free (less than a meg or so?  2M? 3M?)

One program is copying a file (appending) and the other is writing
a file to disk from packets coming across the network.

                                            Any ideas?
                                              ndw

NORM%IONAACAD.BITNET@tecmtyvm.mty.itesm.mx ( Norman Walsh) (02/16/91)

In my previous post about the blockwrite problem, I should have mentioned
that I get an IoResult of 5 if I don't include the optional paramter
to blockwrite that returns the number of bytes written.  Thanks to everyone
whose given me suggestions.  Nothing conclusive has turned up yet.

CDCKAB%EMUVM1.BITNET@cunyvm.cuny.edu ( Karl Brendel) (02/20/91)

In article <9102151241.aa01229@VGR.BRL.MIL>,
  NORM%IONAACAD.BITNET@tecmtyvm.mty.itesm.mx (Norman Walsh) wrote:

>Has anyone ever had any difficulties with the builtin BlockWrite
>function?  Occasionally, Blockwrite fails.  I have been tentative
>about posting this question because I can't believe that the problem
>is in Blockwrite.  What has lead me to post it is that the problem
>has now occured twice.  In two different programs written by
>different developers that do entirely different things.
>
>In both cases the block write indicates that 0 bytes where written
>when there is no reason that I can think of for the write to fail.
>There is certainly enough disk space, it's in a small loop, and the
>file has been written to several times before (i.e. it isn't the
>first time through the loop that fails).
>
>Leads: -It seems to happen on the last write to the file (the last
>        block).

[...remainder deleted...]

Perhaps you could post the code fragments that do the actual opening
of and writing to the files in question.

Note that if the files are opened with a "recsize" > 1, any
BlockWrite which does not write an integral number of "records" will
return a value of "result" which ignores the partial final "record".
In such a case, an attempt to write 1 "record" would return a
"result" of 0 no matter what the reason for failing to write the
complete "record".

When "result" returns as 0, what do IOResult and DOSError return?

Is it possible that an io error is occuring at some other point in
the program, with {$I-}, and IOResult is not being checked there?
That causes a failure of at least some io until IOResult _is_
checked.

+--------------------------------------------------------------------+
| Karl Brendel                           Centers for Disease Control |
| Internet: CDCKAB@EMUVM1.BITNET         Epidemiology Program Office |
| Bitnet: CDCKAB@EMUVM1                  Atlanta, GA, USA            |
|                        Home of Epi Info 5.0                        |
+--------------------------------------------------------------------+