Board index » delphi » A Real Hard 'Case' !

A Real Hard 'Case' !

In article <01bd689d$b7e16c80$LocalHost@default>, a...@{*word*269}.net says...

Quote

>Can any Pascal guru pls explain what I am doing wrong in the attached
>program - {*word*99}s01.pas

>The problem appears on the last Case Statement about 8 lines
>from the end - I keep getting 'Cannot evaluate Expression'

>But I cannot see what I am doing wrong.

>This is an assignment to design a *simple* text based {*word*99}s dice game :)

>If anyone can help or if anyone has written a similar piece of code
>I would be very grateful to hear from you

>TIA
>andy
>a...@{*word*269}.net

Boy, your question made me work, and then I remembered something I read:

A CASE CANNOT WORK WITH VARIABLES!!!!!

you can even try it with a simple program like:
Var I,C:Integer;
Begin
     I:=1;
     C:=2;
     Case I of
        1:Writeln('1');
        C:Writeln('2');
     End;
End.

So I encourage you to use 3 If statements instead...

                                Leor Kehaty,
                                ISRAEL.

p.s. -  there's a begin there than shouldn't be:
        After If (PlayerResponse = 'y') then Introduction; (line 227)

 

Re:A Real Hard 'Case' !


  don't post to de.* in English

Quote
"ajc" <a...@{*word*269}.net> writes:
> The problem appears on the last Case Statement about 8 lines
> from the end - I keep getting 'Cannot evaluate Expression'

couldn't you just have posted that part?!

Quote
> ('the game with a Bankroll of \234 500. The Player places a BET o
> ('the bet may be any value from \243 1 to the maximum value of th

at least one of those will be wrong.  the first was fine on a PC,
the second fine on ISO-8859-1, but neither works on both.

Quote
>   Case Dice_total_Value of
>     7 : Lose;
>     PlayersPoint : If Dice_total_Value = Playerspoint Then Win;

is PlayersPoint a constant?  case requires constants as selectors.

Quote
>     Dice_Total_Value <> 7 OR Playerspoint :

this is not a possible value that Dice_total_Value could take.
and OR binds more tightly than <>, so it's evaluated as

Quote
>     Dice_Total_Value <> ( 7 OR Playerspoint )

which doesn't make sense.

and it's also not a constant.

you're looking for if-then-else-if-then-else, not case, in this part.
--
Russell_Sch...@locutus.ofB.ORG  Shad 86c

Other Threads