1

In my AS-level computing course we're using Turbo Pascal, and for extension work I've been given the task of making a Blackjack/21 style card game. I decided to make a unit for general card game data structures:

unit CardLib;

interface

type
    CardSuite = (clubs, diamonds, hearts, spades);

    Card = record
        name:String;
        value:Integer;
        suite:CardSuite;
    end;

    CardDeck = object
        cards: Array[0..51] of Card;
        freeIndex: Integer;
        constructor init;
        procedure addNewCard(suite:CardSuite, name:String, value:Integer);
        procedure addCard(c:Card);
        function drawCard:Card;
        destructor done;
    end;

    CardHand = object
        cards: Array[0..51] of Card;
        freeIndex: Integer;
        constructor init(deck:CardDeck, size:Integer);
        function getLowestTotal:Integer; {Aces are worth 1}
        function getHighestTotal:Integer; {Aces are worth 11}
        procedure addCard(c:Card);
        destructor done;
    end;
...

I'm compiling this code with Free Pascal in Turbo Pascal compatibility mode, but I'm getting the following error:

CardLib.pas(18,39) Fatal: Syntax error, ")" expected but "," found
Fatal: Compilation aborted
Error: /usr/bin/ppcarm returned an error exitcode (normal if you did not specify a source file to be compiled)

If I comment out the addNewCard procedure, I get the same error in the CardHand constructor instead. Any ideas what's causing this?

Rob Kennedy
  • 161,384
  • 21
  • 275
  • 467
exelotl
  • 494
  • 3
  • 10

1 Answers1

3

Use semicolons to separate the parameters.

procedure addNewCard(suite:CardSuite; name:String; value:Integer);
Rob Kennedy
  • 161,384
  • 21
  • 275
  • 467
C H Vach
  • 100
  • 8
  • That would make sense, I think the var keyword would cause the parameters to be passed as references, which could be desired behaviour for me, but if I use the var keyword I still get the same error. – exelotl Nov 14 '12 at 18:12
  • 1
    I know semicolons are used to end statements but can they be used as a separator here? That's all I got when it comes to guessing. – C H Vach Nov 14 '12 at 18:19
  • Yes, that fixed it! Slightly confusing because parameters of the same time can still be grouped with commas (a,b,c:Integer) and also parameters are passed with commas. I'm used to ActionScript 3 syntax so I assumed that commas would be used for normal procedure declarations too. Cheers, feel free to make an answer for this. – exelotl Nov 14 '12 at 18:29