How to keep track of grouped objects?

LiveCode is the premier environment for creating multi-platform solutions for all major operating systems - Windows, Mac OS X, Linux, the Web, Server environments and Mobile platforms. Brand new to LiveCode? Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
Eric
Posts: 14
Joined: Thu Oct 01, 2009 9:16 am

How to keep track of grouped objects?

Post by Eric » Thu Jul 29, 2010 4:07 pm

Is there any way I can tell what - if any - named group(s) a particular object/control is a member of?

Or, to use an alternative approach, is there any way I can list the member objects of a particular group?

Dixie
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 1336
Joined: Sun Jul 12, 2009 10:53 am

Re: How to keep track of grouped objects?

Post by Dixie » Thu Jul 29, 2010 4:39 pm

Hi Eric...

You can try this...

Code: Select all

   repeat with count = 1 to the number of controls of group 1
      put the long name of control count of group 1 & cr after theList
   end repeat
   
   put theList
be well

Dixie

Klaus
Posts: 14192
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Re: How to keep track of grouped objects?

Post by Klaus » Thu Jul 29, 2010 4:40 pm

Hi Eric,

you could use a repeat loop like this to get a list of all elements of a group:

Code: Select all

...
repeat with i = 1 to the num of controls of grp "Your named group here"
   put the name of control i of grp "Your named group here" & CR after tGroupList
end repeat
delete char -1 of tGroupList
## Get rid of trailing CR
...
This will give you a list like this, the first "word" is the TYPE of control, the second "word" = the short name of that element in quotes:
field "Name of field"
button "my button"
etc...

Hope that helps


Best

Klaus

Curry
Posts: 111
Joined: Mon Oct 15, 2007 11:34 pm
Contact:

Re: How to keep track of grouped objects?

Post by Curry » Fri Jul 30, 2010 12:31 am

also see: owner
Best wishes,

Curry Kenworthy

LiveCode Development, Training & Consulting
http://livecodeconsulting.com/

WordLib: Conquer MS Word & OpenOffice
SpreadLib: "Excel-lent" spreadsheet import/export
http://livecodeaddons.com/

Mark
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 5150
Joined: Thu Feb 23, 2006 9:24 pm
Contact:

Re: How to keep track of grouped objects?

Post by Mark » Fri Jul 30, 2010 8:50 am

Hi Eric,

You might like the scripts.

put the objects of grp x
get the objects of stack y

Best,

Mark
The biggest LiveCode group on Facebook: https://www.facebook.com/groups/livecode.developers
The book "Programming LiveCode for the Real Beginner"! Get it here! http://tinyurl.com/book-livecode

Eric
Posts: 14
Joined: Thu Oct 01, 2009 9:16 am

Re: How to keep track of grouped objects?

Post by Eric » Fri Jul 30, 2010 4:38 pm

Thanks, guys.

All great solutions.

I think "the owner of" was the most ideal for my purposes.
That said, it didn't work perfectly with my nested groups. Strangely, the top group was acknowledged by just one of its two subgroups, and ignored by the other (which instead identified the current card as its owner) - perhaps because the top group is set as a background?


put the objects of grp "Background" produced an odd result.
It didn't trigger any error - but always returned empty!

Mark
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 5150
Joined: Thu Feb 23, 2006 9:24 pm
Contact:

Re: How to keep track of grouped objects?

Post by Mark » Fri Jul 30, 2010 4:44 pm

Eric,

You need to copy those scripts from the website into your mainstack/library stack/backscript.

Mark
The biggest LiveCode group on Facebook: https://www.facebook.com/groups/livecode.developers
The book "Programming LiveCode for the Real Beginner"! Get it here! http://tinyurl.com/book-livecode

Curry
Posts: 111
Joined: Mon Oct 15, 2007 11:34 pm
Contact:

Re: How to keep track of grouped objects?

Post by Curry » Sat Jul 31, 2010 2:51 am

You're welcome! Owner is pretty handy and you can also get the owner of the owner of, etc.
Best wishes,

Curry Kenworthy

LiveCode Development, Training & Consulting
http://livecodeconsulting.com/

WordLib: Conquer MS Word & OpenOffice
SpreadLib: "Excel-lent" spreadsheet import/export
http://livecodeaddons.com/

Eric
Posts: 14
Joined: Thu Oct 01, 2009 9:16 am

Re: How to keep track of grouped objects?

Post by Eric » Sat Jul 31, 2010 11:49 am

Oh, I see.

Got it.

Thanks, Mark.

Post Reply