Accessing custom props using array notation

Kevin Miller kevin at runrev.com
Thu Aug 19 12:00:38 EDT 2010


On 19/08/2010 16:48, "Devin Asay" <devin_asay at byu.edu> wrote:

>> Put the custom prop into an array var, then you can access the contents.
>> 
>> put the uMyArray of btn "test" into tArray
>> put tArray["prop1"] into tVar
> 
> Thanks Chipp. That works if the custom prop is an array to start with, but my
> question is whether it is possible to access all kinds of custom property data
> in the default custom property set using array notation. Here's the situation:
> 
> I have an image object that has several different visual states. The state is
> represented by image data stored in custom properties of the image, labeled
> like this: 
> state1
> state2
> state3
> state4
> 
> When I want to change visual states I simply set the image text to one of the
> custom properties. It would be much easier to do if I could do something like
> this:
> 
>   set the text of img "myImg" to the customKeys["state" & currStateNum] of img
> "myImg"
> 
> Instead, I have to construct clumsy "do" statements to make the changes.
> 
> Unfortunately this doesn't work when using properties in the default set. It
> does work when you have created the properties in your own sets:
> 
>   set the text of img "myImg" to the myPropSet["state" & currStateNum] of img
> "myImg"
> 
>   (From memory, so I may be missing a detail of the syntax.)
> 
> So the question is, can you access non-array data in custom props using array
> syntax when using just the default property set?

Can't you do something like this:

put "xyz" into tVar
set the tVar of btn 1 to "a"

You'll end up with a property called xyz that contains "a" in the default
set.

Kind regards,

Kevin

Kevin Miller ~ kevin at runrev.com ~ http://www.runrev.com/
RunRev - Software construction for everyone





More information about the Use-livecode mailing list