[fpc-pascal] Succ() and Pred() operations
Tomas Hajny
XHajT03 at mbox.vol.cz
Thu Apr 10 03:25:02 CEST 2008
On Wed, April 9, 2008 23:55, Ricardo Viégas wrote:
Hi Ricardo,
> I have installed FPC 2.2.0 [2007/09/09] a few days ago on my
> WinXP-Pro-SP2, and I'm just taking a Web Tutorial on the language.
> when I come to "User defined variable types", I decided to make the
> following test:
>
> Program Test (Output);
> Type Vars = (var0, var1);
> Var x : Vars;
> Begin
> x := var1;
> x := Succ (x);
> Writeln ( Ord(x) );
> x := var0;
> x := Pred (x);
> Writeln ( Ord(x) );
> End.
>
> It compiled and executed without error, and returned following 2 lines:
> 2
> -1
>
> Is that supposed to be the correct output, or should it have pointed an
> error during execution?
> The first symbol of the set has value "0", and second one, value "1". To
> which symbols corresponds the values "2" and "-1"?
It ends up with runtime error 201 if compiled with range checking on
(-Cr), which is a correct behaviour.
Tomas
More information about the fpc-pascal
mailing list