Strange contents of long name

Geoff Canyon gcanyon at gmail.com
Wed Jan 16 18:40:18 EST 2013


On Wed, Jan 16, 2013 at 3:36 PM, Alex Tweedly <alex at tweedly.net> wrote:

> I've always realized there was an issue if  the two contols with the same
> name were at the same level in the control hierarchy - but that is always
> easily avoidable, and seems (almost) acceptable since they have an
> ambiguous long name; I hadn't realized there was this issue with differing
> levels in the control hierarchy. And in this case there is no long name
> ambiguity, and there is also no guarantee of being (easily) able to avoid
> it, since you have less visibility of control names within "custom control"
> groups.



I'll be happy to be proven wrong, but I don't think there is *any sure way*
to reference a control, given only its long name in a stack that isn't
entirely under your control. Examples would include if you're writing
compound controls, or a development tool. For example, suppose your
hierarchy is like this:

stack "kettle"
card id 1002
group "ted"
|  group "alice"
|  |  button "bob"
|  button "Button"
group "alice"
|  button "bob"

(still using Navigator ten years after I stopped working on it...) Then if
you type this in the message box:

set the label of btn "bob" of group "alice" of stack "kettle" to "HA"

The button two levels deep will change its label, despite the fact that you
didn't type of group "ted". This is possible to *any* depth of groups,
making it *impossible* to prevent it completely, although you can make it
very unlikely, obviously. As I said, I don't think there is any way around
this.

Long IDs are your friend here, especially given that you can use them so
cleanly in a variable:

set the label of tID to "HA"

This works a treat, although you have to watch out for changing file
references if you store a long id from one session to the next (and maybe
even during a session? I haven't checked).



More information about the use-livecode mailing list