Re: Understanding {$I-} {$I+} ioResult

Maurice Lombardi <[email protected]>
Newsgroups gmane.comp.compilers.gpc
Message-ID <[email protected]>
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

-- 
        Maurice Lombardi
Laboratoire Interdisciplinaire de Physique,
     (ex Spectrometrie Physique)
Universite Joseph Fourier de Grenoble, BP87
38402 Saint Martin d'Heres Cedex     FRANCE
Tel: 33 (0)4 76 51 47 51
Fax: 33 (0)4 76 63 54 95
mailto:[email protected]

_______________________________________________
Gpc mailing list
[email protected]
https://www.g-n-u.de/mailman/listinfo/gpc
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.