Trapping I/O runtime errors in GPC

Wed, 22 Oct 1997 18:45:28 +0100 (MET)


Is there a (simple) way of trapping runtime I/O errors in GPC, like the {$I-}
compiler directive in Borland Pascal?  Right now, the program

var
  x : real;

begin
  Readln (x);
end.

abort with a run-time error if the user enters something that is not a
number.  The same applies to ReadStr, BTW, so unless there is such a switch
(hidden) in GPC, we have to call C functions like 'sscanf' or 'atof' to
emulate the Borland 'Val' procedure.  However, ReadStr + trapping runtime I/O
errors would be simpler, IMHO.

Jesper Lund



Jesper Lund (jel@hha.dk)

HTML conversion by Lluís de Yzaguirre i Maura
Institut de Lingüística Aplicada - Universitat "Pompeu Fabra"
e-mail: de_yza@upf.es