[fpc-pascal] Why this code fails

Jonas Maebe jonas.maebe at elis.ugent.be
Tue Jan 16 14:26:17 CET 2007


On 16 jan 2007, at 14:04, Alexander Todorov wrote:

> This code compiles with 2.0.4 but gives runtime error 231 .
> program project1;
>
> {$mode objfpc}{$H+}
>
> uses Variants;
>
> var V : Variant;
>    S : String = 'test ';
> begin
>   V := 42;
>   writeln(V);
>
>   S := S + V; // fails here
>   writeln(S);
> end.

The reason is that it tries to convert S to a number rather than V to  
a string. The error is still in the current 2.1.1.


Jonas



More information about the fpc-pascal mailing list