On Thu, 30 Sep 1999, Karl Becker wrote:
> Okay, another question...
> While making a card game (blackjack, specifically) , I've run into a
> little problem. I have a few different variables: player1Hand,
> player2Hand, player3Hand, and so on. In the script, I initialize all of
> them to 0, just to make it easier. However, after getting which player
> the dealer should deal to next, well... I put the following to find the
> loc of where to deal the card:
>
> get "player"& whichPlayerToDealTo &"Hand"
> put the value of it into quickHand --quickHand just a catch-all for all
> --hands used only for a short time
>
> However, there must be a better way than this. All those "get blahblah"s
> are annoying. Even worse, I can't put the value of quickLoc back into
> playerXLoc, since something like the following does not work:
>
> get "player"& whichPlayerToDealTo &"Hand"
> put quickHand into it
>
> So my question: how can I have the contents of a variable point to a
> variable name? If there isn't an indirection operator in MC already
> (which I don't think there is) , maybe it'd be nice to have one?
It might be. It might also be a source of endless confusion ;-)
Certainly you'd have to have some special syntax to distinguish the
cases where you intended to use a reference (like * or & in
C/C++/Java).
> (It'd
> be GREAT for me to have one... and yes, I know I could be putting all the
> values in some array or chunk of text like playerHandValues[2] for
> player2Hand. I'd rather see if there's an indirection thing first.)
Using arrays is how I'd do it, but another possibility would be to use
objects as containers. For example, you could name the buttons after
the players, and then use them as containers:
put quickHand into button ("player" & whichPlayerToDealTo)
put button ("player" & whichPlayerToDealTo) into quickHand
Regards,
Scott
> Thanks much!
>
> --------------------------------
> Karl Becker, [EMAIL PROTECTED]
> http://www.btigate.com/~funkboy/
> Featuring: Tiger's Eye Casino,
> MacBasketball, and The Fishin' Hole!
>
********************************************************
Scott Raney [EMAIL PROTECTED] http://www.metacard.com
MetaCard: You know, there's an easier way to do that...