Page 1 of 1

last group finding a sub group

Posted: Wed Apr 24, 2013 3:46 am
by CenturyMan1979
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?

Re: last group finding a sub group

Posted: Wed Apr 24, 2013 4:08 am
by Simon
How about
delete word 1 to 4 in tID?

Simon

Re: last group finding a sub group

Posted: Wed Apr 24, 2013 5:33 am
by dunbarx
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

Re: last group finding a sub group

Posted: Thu Apr 25, 2013 7:34 pm
by CenturyMan1979
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.

Re: last group finding a sub group

Posted: Thu Apr 25, 2013 9:49 pm
by dunbarx
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