Enumerating the contents of a group

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

Moderators: Klaus, FourthWorld, heatherlaine, kevinmiller, robinmiller

Post Reply
andrew@ugh.net.au
Posts: 13
Joined: Sun Dec 17, 2006 12:30 pm

Enumerating the contents of a group

Post by andrew@ugh.net.au »

Hi,

I have a group containing a number of check boxes. I would like to get a list of all those selected without having to hard code a list of the field names in my script. I was hoping for something along the lines of:

get the members of group "foo"

returning an array of each object in the group. I could then go through, check which ones were buttons and check their highlight etc

Is this possible? Any tips with the syntax?

Thanks,

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

Post by SparkOut »

If you use Mark's handlers found here: http://runrev.info/Objects%20list.htm you can easily

Code: Select all

get the objects of group "theGroupName"
HTH
SparkOut
mwieder
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 3582
Joined: Mon Jan 22, 2007 7:36 am
Contact:

Post by mwieder »

How about something like

Code: Select all

repeat with x=1 to the number of controls of group tGroup
  if word 1 of the name of control x of group tGroup is "button" and the style of control x of group tGroup is "checkbox" then
    put the id of control x of group tGroup into myArray[x]
  end if
end repeat
That would give you your array and you can take it from there.
andrew@ugh.net.au
Posts: 13
Joined: Sun Dec 17, 2006 12:30 pm

Re: Enumerating the contents of a group

Post by andrew@ugh.net.au »

Thanks, that worked.
Post Reply