Page 1 of 1

reference objects inside nested groups

Posted: Mon Dec 06, 2010 8:15 pm
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

Re: reference objects inside nested groups

Posted: Mon Dec 06, 2010 8:35 pm
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

Re: reference objects inside nested groups

Posted: Mon Dec 06, 2010 9:02 pm
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

Re: reference objects inside nested groups

Posted: Mon Dec 06, 2010 9:12 pm
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

Re: reference objects inside nested groups

Posted: Mon Dec 06, 2010 9:28 pm
by kwinkler
Dangerous indeed, as I have discovered. :)