On 26 Nov 2012 at 14:59, Baudouin Le Charlier wrote:
Le 26 nov. 2012 à 12:39, Prof. A Olowofoyeku (The African Chief) a écrit :
On 26 Nov 2012 at 9:10, Baudouin Le Charlier wrote:
[...]
This is a historical factor, and there was no need to duplicate features that Borland already documented well, and which were well known to Borland Pascal/Delphi programmers.
I am not sure they are so well known since you did not explain to me why (i.e. by which miracle) a program that stops abruptly (when compiled with $I-), stops normally if you add a call to ioResult *after* the io statement that makes the original program fail. I doubt very much that this could be explained in the original Borland documentation and also that this behavior should be well known of Borland Pascal programmers.
As I said, the Borland Pascal/Delphi help files are freely available on the net. If you want to use Borland Pascal/Delphi compatibility features in GPC, you would do well to study the Borland documentation on those features.
This is from a 20 year old Borland Turbo Pascal help file:
[--- excerpt begins ---] $I: Input/Output-Checking Switch Enables or disables the automatic code generation that checks the result of a call to an I/O procedure
Syntax: $I+ or $I- Default: $I+ Type: Local Command-Line: /$I+ or /$I- Menu Command: Options|Compiler|I/O Checking
Remarks If an I/O procedure returns a non-zero I/O result when the $I switch is on, the program terminates, displaying a run-time error message.
When the $I switch is off, you must use the IOResult function to check for I/O errors. [--- excerpt ends ---]
Please let us stop this meaningless debate now.
To me, it is not meaningless. I sent you an example where gnu pascal does not conform to the excerpt you just sent me : the program is compiled with the switch off but nevertheless it stops with an error message.
And where in that code did you use the IOResult function to check for errors?
Best regards, The Chief ------- Prof. Abimbola Olowofoyeku (The African Chief) Web: http://www.greatchief.plus.com
Le 26/11/2012 15:18, Prof. A Olowofoyeku (The African Chief) a écrit :
On 26 Nov 2012 at 14:59, Baudouin Le Charlier wrote: And where in that code did you use the IOResult function to check for errors?
Hmm ... May be I see the confusion
You check ioResult in the program lireToto_ioResult.pas in which you have set {$I+}, not in the program lireToto.pas in which you have set {$I-} It is the contrary you must do: if you set {$I+} the programs exits unconditionnally, and it is meaningless to try to check ioResult: you exit before having the opportunity to check it if you set {$I-} the program does not stop, and you have the opportunity to check ioResult, and decide what to do next. A common use of this is for example: if after a read(r) to read a number, you type e.g. an alphabetical letter, error pops up, but is caught, and you have the opportunity to check ioResult, see what happened in considering the error number, and ask to the user to type an other number.
Maurice