Cloning stack reset object IDs?

Pete pete at mollysrevenge.com
Fri Jan 27 14:04:44 EST 2012


Hi Marty,
I've just been playing around with this a bit more and need to clarify a
couple of things.

When you clone a card, it is placed into the currently-open stack, not the
same stack as the original card was in.  So if the stack the original card
is in is open when you clone it, the new card's ID is calculated from the
highest ID on the on the old card.  So yes, you get a new set of IDs, but
they're all higher than what was on the original card, not much use for
what you want to do.

However, you can get help.  Create a new substack of your main stack.  The
card in it will be ID 1002.  Open the new substack, then issue a clone
command from the message box for the card you want to clone.  The new card
will be placed in the new substack and the controls on it will start with
ID 1003.

I haven't taken the last step but you would have delete the stack the card
originated in, then rename the new substack to have the same name as the
original stack.

I think there may well be some gotchas in doing this.  For example, if you
have any behaviors set to the ID of a control on the card, you'd have to
 change them to the ID of the same control on the new card.  There are also
some properties of a datagrid that could be set to a control ID on the card
and those would have to be manually changed also.  Just scan through the
dgProps custom property set and see if you see anything that references a
control on the same card as the datagrid.

I hope that helps.

There's another aspect to this.  Datagrids do use up a lot of control IDs
for sure but I wonder just how much it matters in practical terms.  It
would be interesting to figure out how many times a datagrid would have to
be refreshed to overflow the control ids, by dividing the max possible id
value by an estimate of how many IDs any particular datagrid uses.
 Unfortunately, I don't know what the max id number is - anyone?

Pete

On Fri, Jan 27, 2012 at 9:53 AM, Marty Knapp <martyknapp at comcast.net> wrote:

> Pete,
> So if I'm understanding you correctly, I could clone a card with a
> datagrid and then delete the original card and I would, in effect, start
> with a fresh set of IDs?
>
> Marty
>
>> Hi Richard,
>> Just the datagrid group, not the stack itself.
>>
>> Here's what I see when cloning.  If I clone a card, the controls on it are
>> given a new set of IDs.  If I clone a stack, the controls within the new
>> stack retain the IDs from the original stack.  I guess that's what I would
>> have expected.
>>
>> One other thing I noticed when I was doing this test.  The IDs of the
>> controls I put on the first card I set up for the test weren't numbered
>> consecutively, they were 1004, 1006, 1008, etc.  When I cloned that card,
>> the IDs were consecutive, 1011, 1012, 1013, etc.  Is there a reason why
>> the
>> first card's control IDs went up in 2's?
>>
>> Pete
>>
>>
> ______________________________**_________________
> 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<http://lists.runrev.com/mailman/listinfo/use-livecode>
>
>


-- 
Pete
Molly's Revenge <http://www.mollysrevenge.com>



More information about the use-livecode mailing list