Anything beyond the basics in using the LiveCode language. Share your handlers, functions and magic here.
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller
-
CenturyMan1979
- Posts: 86
- Joined: Tue May 15, 2012 5:56 pm
Post
by CenturyMan1979 » Wed Apr 24, 2013 3:46 am
Hey All,
So I have a main group A. In group A I have a group called B. Group B has a group inside called C. In the card script I have this code,
Code: Select all
put the long id of the last group of group "A" into tID
Problem is I am getting the long ID of group C when I really want the reference to group B. Any way to work around this without having to create a for loop that will search through all the groups in group A to check the name of the groups for the last group B that is found?
-
Simon
- VIP Livecode Opensource Backer

- Posts: 3901
- Joined: Sat Mar 24, 2007 2:54 am
Post
by Simon » Wed Apr 24, 2013 4:08 am
How about
delete word 1 to 4 in tID?
Simon
I used to be a newbie but then I learned how to spell teh correctly and now I'm a noob!
-
dunbarx
- VIP Livecode Opensource Backer

- Posts: 10356
- Joined: Wed May 06, 2009 2:28 pm
Post
by dunbarx » Wed Apr 24, 2013 5:33 am
The "owner" of a subgroup would work your problem in reverse.
But you can still find a child that way, though you would still have to loop through the several groups until the "owner of grp "B" = "group A":
repeat with y = the number of groups down to 1
if the owner of group y = group "A" then put the long id of group y
end repeat
A problem might come up when more than one group is owned by group "A", but in the case you put out, this would not occur.
Craig Newman
-
CenturyMan1979
- Posts: 86
- Joined: Tue May 15, 2012 5:56 pm
Post
by CenturyMan1979 » Thu Apr 25, 2013 7:34 pm
Both suggestions work great but "owner" is what I was looking for. Just deleting words from the long ID could leave me open to issues in the future.
Thank you both for taking the time to post a response.
-
dunbarx
- VIP Livecode Opensource Backer

- Posts: 10356
- Joined: Wed May 06, 2009 2:28 pm
Post
by dunbarx » Thu Apr 25, 2013 9:49 pm
Good.
But be aware that the keyword "last" is not stable for groups. Works everywhere else, though. Read my user note in the dictionary under "last.
I think the "owner" path is better for this reason.
Craig Newman