Iterating over objects in a group?

Anything beyond the basics in using the LiveCode language. Share your handlers, functions and magic here.

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
massung
Posts: 93
Joined: Thu Mar 19, 2009 5:34 pm

Iterating over objects in a group?

Post by massung » Wed Jan 20, 2010 6:55 am

Sorry if this is covered somewhere, but I've been looking and can't seem to find it. What I'd like to do is send a message to all the objects in a group. For example (pseudo code):

Code: Select all

command savePrefs
   get objects in group "GroupName"

   repeat for each line tLongID in it
      send "savePrefs" to tLongID
   end repeat
end savePrefs
Just curious if this is doable somehow?

Thanks!

Jeff M.

sturgis
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 1685
Joined: Sat Feb 28, 2009 11:49 pm

Re: Iterating over objects in a group?

Post by sturgis » Wed Jan 20, 2010 7:37 am

YOu can do something like this:

Code: Select all

on mouseUp
   repeat with i = 1 to the number of controls in group "myGroup"
     put the long id of control i of group "myGroup" into tId
     send savePrefs to tId 
   end repeat
end mouseUp


command savePrefs
     --    save your prefs here
end savePrefs

Post Reply