Copy to Group problems - solved!

user alanira9 at mac.com
Mon Jan 16 15:17:09 EST 2012


First of all, thanks to all of you who offered advice on this problem, with special thanks to Craig Newman for definitively pointing out that "The "last" keyword is not stable when referring to groups." - apparently a LC bug

After doing a little exploring through the dictionary for a workaround, I discarded the "copy" and "create" options (both not dependable, but for different reasons), but found that the "clone" command works just fine, as it puts the long id of the newly created group into the "it" variable, after which it was a piece of cake to rename and reposition the new group.  No "newGroup" handler required this time around, but some sort of "newObject" handler might be helpful under other circumstances.

Here's the working code, which is quite straightforward, AND WORKS!

on addFldDoublet theGroup
   put the number of grps in grp theGroup into lastDoublet
   put the short name of grp lastDoublet of grp theGroup into lastName
   put the left of grp lastName into newLeft
   put (the bottom of grp lastName -6) into newTop
   put lastName into nextName
   set itemDelimiter to "_"
   add 10 to last item of nextName
   set itemDelimiter to ","
   clone grp lastName
   set the name of it to nextName -- The clone command places the long id property of the newly created object in the it variable.
   set the left of grp nextName to newLeft
   set the top of grp nextName to newTop
end addFldDoublet

Knowing that the "last" keyword was the problem did the trick, and I'm not likely to waste time in the future trying to directly reference a "last" object until I'm sure the bug has been fixed.  

But the truth is that it was the combined input of all who offered their advice that put me on the correct track to solving this one, and I am grateful for kind assistance.

Regards,
Alan Gayne



More information about the use-livecode mailing list