Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

read and write procedure with enumerated type

neonkasneonkas Posts: 2Member
hi at all !

Excuse me for my scholastic english.
I'm testing the free pascal compiler of Lazarus 0.9.3

My pascal program

type
verb=(find,talk,learn,eat);
var
v:verb;
begin
readln(v);
write(v);
readln;
end.

I tested this program: it's wrong for TP7 and good for Lazarus.
My turbo pascal guide says I cannot read and write an enumerated type.
So my question is: is it a difference or a Lazarus/free pascal error?


other program

type
subra=1..10;
var
i:subra;
begin
i:=succ(10);
write(i);
readln;
end.

the same: it's wrong for tp7 and good for Lazarus even if it shows the message 'warning range check error while evaluating constants'.

My question is: Lazarus executes this program, is it a compiler problem?


Thanks in advance for your answers



Comments

  • skidellllsskidelllls Posts: 4Member
    i have the same question
    can sb tell how to do it?
    [link=http://www.programmersheaven.com]02.05.1994llls[/link]
  • skidellllsskidelllls Posts: 4Member
    i have the same question
    can sb tell how to do it?
    [link=http://www.programmersheaven.com]02.05.1994llls[/link]
  • skidellllsskidelllls Posts: 4Member
    i have the same question
    can sb tell how to do it?
    [link=http://www.programmersheaven.com]02.05.1994llls[/link]
  • Actor21Actor21 Posts: 35Member
    [red]
    : hi at all !
    :
    : Excuse me for my scholastic english.
    : I'm testing the free pascal compiler of Lazarus 0.9.3
    :
    : My pascal program
    :
    [code]
    type
    verb=(find,talk,learn,eat);
    var
    v:verb;
    begin
    readln(v);
    write(v);
    readln;
    end.
    [/code]
    :
    : I tested this program: it's wrong for TP7 and good for Lazarus.
    : My turbo pascal guide says I cannot read and write an enumerated
    : type.
    : So my question is: is it a difference or a Lazarus/free pascal
    : error?
    [/red]
    There must be a difference. In TP the way you key in [italic]find,talk,learn,eat[/italic] is undefined.
    [red]
    :
    :
    : other program
    :
    [code]
    type
    subra=1..10;
    var
    i:subra;
    begin
    i:=succ(10);
    write(i);
    readln;
    end.
    [/code]
    :
    : the same: it's wrong for tp7 and good for Lazarus even if it shows
    : the message 'warning range check error while evaluating constants'.
    :
    : My question is: Lazarus executes this program, is it a compiler
    : problem?
    [/red]
    I don't know why Laz executes it. It shouldn't. [b]succ(10)[/b] is 11, which is outside the range of [b]i[/b].

Sign In or Register to comment.