Copy to Group problems

dunbarx at aol.com dunbarx at aol.com
Sun Jan 15 13:24:20 EST 2012


The keyword "last"is not stable with groups. I think this is the only object where this breaks down. See the dictionary.The workaround uses the "templateGroup":



The "last" keyword is not stable when referring to groups. So if one creates several groups, referencing the "last" group may not return the group actual ly created last. Using the "templateGroup" is a workaround, since when creating a new group one can, for example, set the name of the templateGroup to something unique, and be able to find the last group by name. Also, trapping the "newGroup" message with an appropriate script can be used to find the last group.


This is not an issue with other objects,


Craig Newman



-----Original Message-----
From: Pete <pete at mollysrevenge.com>
To: How to use LiveCode <use-livecode at lists.runrev.com>
Sent: Fri, Jan 13, 2012 11:49 am
Subject: Re: Copy to Group problems


Not sure if you'll classify this as "help" but I've had problems in the
past referring to "the last group" not returning what I considered to be
the last group, although I can't explain what you see in your answer
commands.

The dictionary doesn't mention if the copy command returns the id of the
copied control in the it variable - if it does, you could use that to refer
to the newly copied group.

I believe I ended up using the create command instead of copy, which does
return the id in the it variable, and then making all my adjustments by
referring to it.

Good luck!

On Fri, Jan 13, 2012 at 12:55 PM, user <alanira9 at mac.com> wrote:

> Hi everyone,
>
> I have a script intended to add, name and position a label and field group
> (which I refer to as a "doublet) into a group that already has a number of
> such doublet groups.
>
> Here's the script:
>
> 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 +2) into newTop
>   put lastName into nextName
>   set itemDelimiter to "_"
>   add 10 to last item of nextName
>   set itemDelimiter to ","
>   copy grp lastName to grp theGroup
>   set the name of the last grp to nextName
>   answer the short name of the last grp -- confirms the correct name
>   put the short name of the last grp into newGrp
>   answer newGrp -- confirms the correct name
>   set the left of grp newGrp to newLeft
>   set the top of grp newGrp to newTop
> end addFldDoublet
>
> FYI - assume the name of grp lastDoublet is "DB_Doublet_160"
>
> Group newGrp is supposed to be "DB_Doublet_170" and this appears to be
> confirmed by the two "answer" commands I've inserted in the script to
> verify.
>
> But after the script runs, it turns out that the new group is also named
> "DB_Doublet_160" instead of "DB_Doublet_170" (which does not seem to exist,
> even though the second "answer" test shows that it did ), and the new group
> is positioned right on top of the old group, and not offset to to newTop as
> desired (2 pixels below the bottom of the old group.
>
> Anybody have any idea as to what is causing this script to not work as
> intended?
>
> Thanks in advance for your help in this matter.
>
> Kind regards,
> ALAN GAYNE
>
> _______________________________________________
> use-livecode mailing list
> use-livecode at lists.runrev.com
> Please visit this url to subscribe, unsubscribe and manage your
> subscription preferences:
> http://lists.runrev.com/mailman/listinfo/use-livecode
>
>


-- 
Pete
Molly's Revenge <http://www.mollysrevenge.com>
_______________________________________________
use-livecode mailing list
use-livecode at lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode

 




More information about the use-livecode mailing list