Object naming
Andre Garzia
andre at andregarzia.com
Mon Jul 27 10:40:36 EDT 2020
Alex,
I think that Mark solution is the correct one but I couldn't resist telling
you some other idea, one that is only applicable if performance is not a
problem.
You can add custom properties to controls you want to find later and then
look for them by looping everyone in the card. A reusable short function
can be created with whatever letter you want, like "q", and code similar to
this:
function q selector, value
repeat with x = 1 to the number of controls in this card
if the selector of control x of this card is value then
return the long id of control x of this card
end if
end repeat
end function
And then you can go:
put q("blue-rect", "true") into tLongID
You can even have something like "qq" that returns a list of long ids for
all the controls that match that query. Caching these results is the best
architecture, on preOpenCard you can find all the controls you'll need and
place them in script local arrays, then all the functions that need them
can peek into those arrays.
It is a bit convoluted but allows for some clever programming. Remembering
that "clever" is one of the trickster spirits of the software development
world.
Best
A
On Mon, 27 Jul 2020 at 01:33, Alex Tweedly via use-livecode <
use-livecode at lists.runrev.com> wrote:
> I think my head is melting :-)
>
> I have a group called 'A'.
>
> Inside A, there is a rect called "R" and also a group called "B"
>
> inside B there is a rect called "R"
>
> How do I refer unambiguously to the first rectangle (i.e. A - R, not A -
> B - R) ?
>
> If I say
> grc "R" of grp "B" of grp A
> then I unambiguously get A-B-R; but if I say simply
> grc "R" of grp "A"
> then I *also* get A-B-R.
>
> There must be a way to do this (and maybe if it wasn't nearly 2 in the
> morning I would be able to figure it out).
>
> Help! Please !
>
> Alex.
>
>
> _______________________________________________
> 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
>
--
https://www.andregarzia.com <http://www.andregarzia.com>
Want to support me? Buy me a coffee at https://ko-fi.com/andregarzia
More information about the use-livecode
mailing list