Stability of a button's ID property when cloning stacks

Anything beyond the basics in using the LiveCode language. Share your handlers, functions and magic here.

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Simon Knight
Posts: 919
Joined: Wed Nov 04, 2009 11:41 am

Re: Stability of a button's ID property when cloning stacks

Post by Simon Knight » Thu Jun 25, 2020 10:12 am

Here is an additional observation.

Richard's post explains that a stack's ID number is only a placeholder for the next ID to be allocated and that the text name has to be unique. However, Livecode allows a sub stack to have the same name as another stack as long as it does not share the same main stack. It even seems to allow the sub stack to have the same name as the main stack. However don't try either of these as the IDE does not like it and gets into a bit of a tizzy.

The dictionary implies that the stack name is really a placeholder for the file name of the stack file which is one reason why it has to be unique, that should mean that sub stacks can share the same name but it appears not to be the case.
best wishes
Skids

jacque
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 7393
Joined: Sat Apr 08, 2006 8:31 pm
Contact:

Re: Stability of a button's ID property when cloning stacks

Post by jacque » Thu Jun 25, 2020 5:44 pm

I had identical problems when I needed to change the name of the mainstack. All behavior references broke. Since it was just a single stack in development I manually changed all the references, but yes, it's an issue.

I think your only solution is the one you've found. After copying the control group, set the behavior of the grouped controls to the ID of the behavior button. As long as your group does not have duplicate named controls and you specify your group as the container to look in, it should be quite safe.
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com

FourthWorld
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10055
Joined: Sat Apr 08, 2006 7:05 am
Contact:

Re: Stability of a button's ID property when cloning stacks

Post by FourthWorld » Thu Jun 25, 2020 7:08 pm

I tend to put behavior scripts, icon images, and other shared resources into a substack dedicated for that purpose.

I name that substack something unique and distinctive, often ending with "RSRC" (e.g., "MyAppRSRC") so it's easy to identify in IDE stack listings, and reminds me clearly that the stack itself isn't user-facing.

Even if I need to change the name of any user-facing stack, I generally don't need to also change the name of the RSRC stack, so any references will continue to work well even through a long, iterative development cycle subject to change.

And truth be told, I rarely change the name of even user-facing stacks, since LC renders the name with the card number or asterisk,which is rarely what I want anyway. I rely on the stack's title property for a user-facing label, with the actual name only used in scripts the user never sees.
Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn

Post Reply