Object naming

Martin Koob mkoob at rogers.com
Mon Jul 27 23:04:55 EDT 2020


Hi Alex

You could use the owner of the control in conjunction with the name of the control to distinguish between the two graphic’s named ‘R’.

I did that  for the  simple case in your example  but may not work with something more complex.

I created a stack with the same hierarchy of graphics and groups and using the following scripts in a button I placed on the card I can distinguish between  graphic A - R and B - R.


on mouseup

ask “enter owner name/control name/control colour"

put it into tResponse 

set the itemdelimiter to "/"

put item 1 of tResponse into tOwner

put item 2 of tResponse into tControl

put item 3 of tResponse into tControlColour

put findTargetControl(tOwner, tControl) into tTargetControl

set the backgroundcolor of control tTargetControl of group "A" to tControlColour

end mouseup


function findTargetControl pOwner, pControl

put the number of controls  of group "A" into tIndex

repeat with tControl = 1 to tIndex

if the short name of control tControl of group "A" = pControl then

if the short name of the owner of control tControl of group "A" = pOwner then

exit repeat

end if

end if

end repeat

return tControl

end findTargetControl


Martin Koob



> On Jul 27, 2020, at 8:47 PM, Alex Tweedly via use-livecode <use-livecode at lists.runrev.com> wrote:
> 
> 
> On 27/07/2020 21:26, Curry Kenworthy via use-livecode wrote:
>> 
>> Use unambiguous SHORT names!
>> 
> Thanks, but ...
> 
> Yes, using unambiguous SHORT names solves this naming problem, but introduces other problems. In particular, this group script should (probably) be a behaviour script, since the group will be instantiated multiple times and will in the future need updating for enhancements or even (Heaven forfend!) bug fixes.
> 
> Using unambiguous short names prevents behaviour scripts that references child controls completely, and even if I simply used normal scripts which were replicated for each instance, I'd still need to go through the script to change all the references to the child control names (a pain, and source of possible future errors).
> 
> For now, I'm caching the IDs of the direct child controls in script-local variables in each instance of the group. If I find a name-based way that works reliably and allows behaviour scripts, I'll change - but this method works.
> 
> I'll have this group ready for release soon (or soon-ish) so y'all'll be able to see how it turned out :-)
> 
> Thanks again everyone,
> 
> 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




More information about the use-livecode mailing list