reference objects inside nested groups

Got a LiveCode personal license? Are you a beginner, hobbyist or educator that's new to LiveCode? This forum is the place to go for help getting started. Welcome!

Moderators: Klaus, FourthWorld, heatherlaine, kevinmiller

Post Reply
kwinkler
Posts: 61
Joined: Fri Nov 26, 2010 5:59 am

reference objects inside nested groups

Post by kwinkler »

I'm sure there is a simple solution, but I can't seem to find it.

I have created a group of objects within another group. Group "xGrid" is inside group "plotGroup". How can I reference the objects inside "xGrid"? The following command gives the error (set: missing 'to'), but clearly I have a 'to' in there. Do I need to add parentheses somewhere? Any suggestions would be appreciated.


set the rectangle of graphic "xGrid"&i of grp "xGrid" of grp "plotGroup" to round(x2+x1)/2 , y1 , round(x2+x1)/2 , y2
Klaus
Posts: 14325
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Re: reference objects inside nested groups

Post by Klaus »

HI kwinkler,

1. if you have unique names, you will be able to just use the name to address an object.
You DO have unique names, do you?! :D

2. you MUST use parenthesis when addressing objects with concatenated strings like in your example!
...
set the rectangle of graphic ("xGrid" & i) to round(x2+x1)/2 , y1 , round(x2+x1)/2 , y2
...


Best

Klaus
kwinkler
Posts: 61
Joined: Fri Nov 26, 2010 5:59 am

Re: reference objects inside nested groups

Post by kwinkler »

Klaus,

The parentheses seem to have solved the problem. Since the number of objects inside the group frequently varies, it seems like unique names could be cumbersome.

Thanks,

Ken
Klaus
Posts: 14325
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Re: reference objects inside nested groups

Post by Klaus »

Hi Ken,
kwinkler wrote:The parentheses seem to have solved the problem.
It not only seems, it really does :D
kwinkler wrote:Since the number of objects inside the group frequently varies, it seems like unique names could be cumbersome.
Ah, looks like you are creating graphics dynamically, then you are right of course!

Nevertheless 2 or more objects with the same name can be dangerous! 8)


Best

Klaus
kwinkler
Posts: 61
Joined: Fri Nov 26, 2010 5:59 am

Re: reference objects inside nested groups

Post by kwinkler »

Dangerous indeed, as I have discovered. :)
Post Reply