[fpc-devel] How to avoid Runtime error 231?

Jonas Maebe jonas.maebe at elis.ugent.be
Sun Jun 1 15:06:18 CEST 2008


On 01 Jun 2008, at 14:58, Dusan Halicky wrote:

> I have following test program:
>
> {$mode delphi}
> var a,b : variant;
> begin
>  a := 'foo';
>  b := 5;
>  writeln(a+b);    // here Runtime Error appear
>  // ... other code
> end.
>
> But I need to continue to work, even after Runtime Error 231, I've
> tried try-except

You have to use the sysutils unit if you want run time errors to be  
converted into exceptions:

{$ifdef fpc}
{$mode delphi}
{$endif}
uses
   SysUtils;
var a,b : variant;
begin
  try
    a := 'foo';
    b := 5;
    writeln(a+b);    // here Runtime Error appear
  except on Exception do
    writeln('caught');
  end;
  writeln('other code');
  // ... other code
end.


Jonas



More information about the fpc-devel mailing list