At 11:37 PM -0700 9/20/05, Leonard White wrote:
That is, I want to evaluate "prop_" + variable, where variable =
"stamina" and the property I'm trying to set is called
"prop_stamina", say.
So the property name is first constructed then I can access the
resulting string AS as property name.
There are a couple ways to do this, some of which (Operator_Lookup)
give up compile-time checking of your code (like scripting
lanugages), so I wouldn't recommend that.
Instead, when I need this, I just add GetProp and SetProp methods,
each of which has a Select Case that sets/gets the appropriate
property based on the given property name. Yes, this means you have
to update these two functions whenever you change the set of
properties, but in the context of all the work needed to write a
game, this is trivial.
Best,
- Joe
--
Joe Strout REAL Software, Inc.
Vote for REALbasic (twice!) in the LinuxWorld Reader's Choice Awards:
http://linux.sys-con.com/general/readerschoice.htm
_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>
Search the archives of this list here:
<http://support.realsoftware.com/listarchives/lists.html>
|