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

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: FourthWorld, heatherlaine, Klaus, kevinmiller

Post Reply
atout66
Posts: 266
Joined: Wed Feb 02, 2011 12:31 pm

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

Post by atout66 » Wed Jun 03, 2015 6:33 am

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.
Last edited by atout66 on Wed Jun 03, 2015 7:53 am, edited 1 time in total.
Discovering LiveCode Community 6.5.2.

atout66
Posts: 266
Joined: Wed Feb 02, 2011 12:31 pm

Re: How do I refer objects from a group ?

Post by atout66 » Wed Jun 03, 2015 6:38 am

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"
Discovering LiveCode Community 6.5.2.

SparkOut
Posts: 2961
Joined: Sun Sep 23, 2007 4:58 pm

Re: How do I refer objects from a group ?

Post by SparkOut » Wed Jun 03, 2015 7:38 am

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).

atout66
Posts: 266
Joined: Wed Feb 02, 2011 12:31 pm

Re: How do I refer objects from a group ?

Post by atout66 » Wed Jun 03, 2015 7:53 am

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.
Discovering LiveCode Community 6.5.2.

SparkOut
Posts: 2961
Joined: Sun Sep 23, 2007 4:58 pm

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

Post by SparkOut » Wed Jun 03, 2015 8:08 am

I still wish we had a

Code: Select all

repeat for each control tControl of this card
type option

Post Reply