Target and me. Target not the correct value

Matt Denton matt.denton at limelight.com.au
Sun Aug 8 21:16:52 CDT 2004


Hey ho.

Just found a small discrepancy: the 'me' function will always return 
the correct object, however 'the target' will only return the name of 
the object.  This becomes an issue if you, like me, sometimes duplicate 
an object and forget to give it a unique name.  Create a button, put 
this script in it:
	
on closeField
   put the value of me
end closeField

Now duplicate (or option-drag) a copy.  Change text in the field, 
notice the correct values are reported back to the msg window. Now 
change BOTH scripts to:

on closeField
   put the value of the target
end closeField

... this reports incorrectly, only reporting 1 field (the first found 
with the name 'Field 1').  I kinda remember in my dim past that 
HyperCard would always return the target value correctly, even with 
object name duplication?

Confusingly, just 'target' (no 'the') returns the value correctly; 'the 
value of the target' doesn't when there is a duplicate name.  Small, 
simple, but had me stumped for a bit.  As you might expect, 'put the 
value of (long ID of the target)' works.  Of course avoiding 
duplication is good practice; not trusting 'the target' is safest if 
you can't guarantee unique field/group/button etc names.

I'd like to see 'the target' use the long ID for object referencing, 
but use the name of the target (as it does now) when used for display.  
Is that possible?  Anyone agree?

Bye

M@
Matt



More information about the use-livecode mailing list