Le 25 nov. 2012 à 15:13, Prof A Olowofoyeku (The African Chief) a écrit :
On 25 Nov 2012 at 12:13, Baudouin Le Charlier wrote:
It seems that {$I-} is not enough to disable the automatic handling of IO errors.
I doesn't disable error checking. It just stops it from automatically terminating the program immediately it encounters an I/O error.
That's what I finally guessed but not what was explained in the documentation I could find.
But you must check IOResult, to see whether there is an error, and so handle the error yourself (or ignore the error), but, crucially, to clear the error flag.
That also was not clearly stated in the documentation. It was said that ioResult checks what happened during the last IO operation not that you have to call ioResult to clear the error flag. Why not to update the error flag afresh each time an IO operation is performed ?
You also have to actually write a call to ioResult in the program. Seems to me that this is not a correct behaviour.
It is the correct behaviour. What is the point of preventing I/O errors from terminating the program if you will not check to see whether there has been an error? Just allow the program to keep running and keep generating errors that no-one is interested in checking?
Yes, this can be perfectly meaningful in cases where you cannot correct the error but you need to continue executing the program for more important or simply other purposes.
Anyway, more importantly, can you explain why the fact of calling ioResult *after* the erroneous IO operation prevents abnormal termination while not calling ioResult *with {$I-} enabled* does not prevent it ? I do not understand how that is possible unless some kind of static analysis of the program is done at compile time.
Thanks,
Baudouin