# Pascal Code.

Page 1 of 1

## 3 Replies - 3152 Views - Last Post: 12 April 2005 - 05:21 PMRate Topic: //<![CDATA[ rating = new ipb.rating( 'topic_rate_', { url: 'https://www.dreamincode.net/forums/index.php?app=forums&module=ajax&section=topics&do=rateTopic&t=10628&amp;s=a73004a1b209d11e7c6565486f6ff7c8&md5check=' + ipb.vars['secure_hash'], cur_rating: 0, rated: 0, allow_rate: 0, multi_rate: 1, show_rate_text: true } ); //]]>

### #1 Sarah.K

Reputation: 0
• Posts: 2
• Joined: 13-March 05

# Pascal Code.

Posted 13 March 2005 - 07:03 PM

Hi,
I have the following code and just wondered if anyone could tell me why it doesnt compile and what edits I need to do to make it work.
It's basically a card game which follows these rules:

1) Imagine computer randomly selects a card from a pack of cards.
2) The first player must guess the suit then its value
3) After each guess for the suit a message will display whether the
player was correct or not.
4) After each guess for the value a message will display whether the
player was correct, too high or too low.

Here is the code:
```procedure game;
var suitguess,valueguess : string;
valueguessint, suitguessint,valid : integer;
validbool : boolean;

begin
generateno;
guesses := 0;

repeat
suitcorrect := false;
valuecorrect := false;
repeat
Writeln('Enter Suit Guess');
writeln;
writeln('1 : Club');
writeln('3 : Heart');
writeln('4 : Diamond');
writeln;
writeln;

val(suitguess, suitguessint, valid);
validbool := true;
if (suitguessint <1) or (suitguessint >4) or (valid <> 0) then
begin
validbool := false;

writeln('Please enter a number from 1 to 4');

writeln('Press any key to try again');
end;
until validbool = true;

If suitguessint = suitno then
begin
writeln('Correct');
suitcorrect := true;
end
else
writeln('Incorrect');

begin
repeat
Writeln('Enter Value Guess');
writeln('1  = ace');
writeln('11 = jack');
writeln('12 = queen');
writeln('13 = king');
writeln('all other numbers are represented by thier number value');
writeln;
val(valueguess, valueguessint, valid);
validbool := true;
if (valueguessint <1) or (valueguessint >13) or (valid <> 0) then
begin
validbool := false;

writeln('Please enter a number from 1 to 13');

writeln('Press any key to try again');
end;
until validbool = true;

If valueguessint = value then

begin
writeln('Correct');
valuecorrect := true
end

else
begin
writeln('Incorrect');

If value < valueguessint then
writeln(' The value is less than ',valueguess)
else
writeln(' The value is greater than ',valueguess);
end;
end;
guesses := guesses +1;

until (suitcorrect AND valuecorrect) = true;

writeln('Game complete');
writeln('press any key to continue to next game');
totalguesses[activeplayer(gameno)] := totalguesses[activeplayer(gameno)] + guesses;
end; {proc}
```

The code was part of a bigger code and has been edited a bit. Now I believe I just need to put a start, end and add the variables etc to make it run as a single game. If anyone fancies taking a stab at it I would be most grateful.
Ideally im trying to get the code into an executable form so the game plays as described.

Thanks.

This post has been edited by Sarah.K: 13 March 2005 - 07:06 PM

Is This A Good Question/Topic? 0

## Replies To: Pascal Code.

• g+ + -o drink whiskey.cpp

Reputation: 250
• Posts: 13,507
• Joined: 12-July 02

## Re: Pascal Code.

Posted 13 March 2005 - 07:53 PM

What errors are you getting on compilation? It may help to narrow down the problem...although not likely for me. I haven't touched pascal in forever.

### #3 born2c0de

• printf("I'm a %XR",195936478);

Reputation: 187
• Posts: 4,673
• Joined: 26-November 04

## Re: Pascal Code.

Posted 13 March 2005 - 09:59 PM

I've programmed quite a lot with pascal but i just dont use it anymore...meaning I dont have a pascal compiler. What compile errors are you getting? Once I get those I can help you out...( because at first glance, your code seems clean enough )

### #4 SusiTohir

Reputation: 0
• Posts: 6
• Joined: 07-April 05

## Re: Pascal Code.

Posted 12 April 2005 - 05:21 PM

I think you should declare many variables on your code such suitno, gameno...etc. You can check again.

Page 1 of 1

 .related ul { list-style-type: circle; font-size: 12px; font-weight: bold; } .related li { margin-bottom: 5px; background-position: left 7px !important; margin-left: -35px; } .related h2 { font-size: 18px; font-weight: bold; } .related a { color: blue; }