Page 1 of 1

How do I refer objects from a group ? [Solved]

Posted: Wed Jun 03, 2015 6:33 am
by atout66
Hi to all,

Sorry for this simple question but any idea how do I refer objects from a group ?
I want to place an handler in a group which init all its child objects.
This script example below (in the group) explain a bit:

Code: Select all

on initAll
    send initYourSelf to objects of me    
end initAll
I suppose this code won't work, even if the syntax seems OK, as the <objects> keyword in the dictionnary doesn't match exactly my needs...
I've seen in the dictionnary that they talk about "objectList", under the group page, but I didn't find any "objectList" entry...

Thanks for your help,
Regards, Jean-Paul.

Re: How do I refer objects from a group ?

Posted: Wed Jun 03, 2015 6:38 am
by atout66
To go further I also tried this in the command box, without success :?

Code: Select all

put the list of objects of group "grp_lesCoches"

Re: How do I refer objects from a group ?

Posted: Wed Jun 03, 2015 7:38 am
by SparkOut
Nearly there

Code: Select all

repeat with i = 1 to the number of controls of group "grp_lesCoches"
      send "initYourself" to control i of group "grp_lesCoches"
end repeat
You can also do appropriate actions such as initialising only buttons (given a suitable naming convention)

Code: Select all

repeat with i = 1 to the number of controls of group "grp_lesCoches"
      if the short name of control i of group "grp_lesCoches" begins with "btn" then
            send "initYourself" to control i of group "grp_lesCoches"
      end if
end repeat
or you could do the same but specifying whether the long name includes button or field etc.(although that would be completely unnecessary, as you would just repeat with i = 1 to the number of buttons of group "grp_lesCoches", but you get the idea, I hope).

Re: How do I refer objects from a group ?

Posted: Wed Jun 03, 2015 7:53 am
by atout66
The "number of controls ", didn't know that; fantastic !
Yes, I got the idea, and thanks a lot, SparkOut, for this great lesson ;-)

Regards, Jean-Paul.

Re: How do I refer objects from a group ? [Solved]

Posted: Wed Jun 03, 2015 8:08 am
by SparkOut
I still wish we had a

Code: Select all

repeat for each control tControl of this card
type option