Talk About Network

Google


Register and Login
Nick
Password
Register create new account Sign up is FREE and you can post replies, new topics, bookmark posts and more!
Recover lost password


Programming > Pascal Borland > Re: Not underst...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 2 of 4 Topic 1032 of 1118
Post > Topic >>

Re: Not understanding these 2 variables

by "Bill Leary" <Bill_Leary@[EMAIL PROTECTED] > Jun 2, 2007 at 12:50 PM

"roofy" <rneilen216@[EMAIL PROTECTED]
> wrote in message 
news:1180800856.979324.321980@[EMAIL PROTECTED]
'm a little rusty on Pascal, but let's have a go...

> What I do not understand in the first variable is the = (PAWN, ROOK,
> KNIGHT ...etc. How could one variable equal another undefined variable
> not to mention that their are six undefined variables that point to
> PieceImageType.

It's not a variable, it's a defining a new data type.  One which can have 
one of six values, those values being PAWN, ROOK, and so on.

In C:

enum PieceImageType {PAWN, ROOK, KNIGHT, BISHOP, QUEEN, KING};

> The second defined variable is that I do not
> understand the concept of how the programmer was defining
> PossibleMoves as an array. If I understand correctly, when defining an
> array, the part that is inside the brackets is what defines the size
> of the array.

I'm assuming that the PossibleMoveType as in the Type section along with 
PieceImageType rather than the Var section.

So, it's defining a type PossibleMoveType which is a six element array
with 
indexes PAWN, ROOK, and so on.

And, later there should be something like

    Var Moves: PossibleMoveType;

which would then permit, in the code section:

    Moves[ROOK].NumDirections := 3;
    Moves[KING].UnitMove[3].DirRow := -1;

or there might be:

    ThisPiece: PieceImageType;

in the Var section, allowing this usage in the code section:

    ThisPiece := BISHOP;

    if Moves[ThisPiece].MaxDistance = 3 then

and so on.

    - Bill
 




 4 Posts in Topic:
Not understanding these 2 variables
roofy <rneilen216@[EMA  2007-06-02 09:14:16 
Re: Not understanding these 2 variables
"Bill Leary" &l  2007-06-02 12:50:30 
Re: Not understanding these 2 variables
roofy <rneilen216@[EMA  2007-06-02 20:58:14 
Re: Not understanding these 2 variables
"bradclark1@[EMAIL P  2007-06-05 07:58:46 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
tan12V112 Sat Jul 26 5:47:05 CDT 2008.