Target and me. Target not the correct value
Robert Brenstein
rjb at rz.uni-potsdam.de
Mon Aug 9 11:30:29 EDT 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
How does your button get the closefield message? This message is sent
to the field but it is not passed to any button.
>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 pulls the content of the target not the target name. May be you
mean to use the 'short name of the target'?
>... 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?
the target function returns 'field "fldname"' or "button "btnname' so
it indeed confusing if you have multiple objects of the same kind
with the same name. I think you will always get the one in lower
layer. It was the same in HyperCard I believe. If your objects have
no names, then the object id is used and the target reference is
unique.
>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.
I get the same result regardless whether I have the or not in front
of the target. This is curious in itself. Without the, it should not
be recognized as a function.
>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.
Hmm, curious that the long id of the target works. The target should
still resolve ambiguously, so getting long id of that object should
not fare any better. But I verified that indeed the result is
correct. May be there is some preference to the current object. But
then a parallel construct with value fails. I verified that it is
indeed the case. It would seem that engine parses these differently.
>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?
You are asking to change the syntax of Transcript which transpired
from HyperTalk. That could result in compatbility issues with
existing software.
Robert
More information about the use-livecode
mailing list