Question about Object Names
Richard Gaskin
ambassador at fourthworld.com
Fri May 27 10:57:56 EDT 2011
Todd Geist wrote:
> I am confused by an inconsistency I am seeing. I think it points to
> something I missing about object names and references.
>
> Using the Object Inspector you can set the name of a card, for example, to
> "MyCardName"
>
> But when you retrieve the name of the object in line of code you get back
> the object type followed by the name in Quotes, like this
>
> *put *the name of the this card into tCard
>
>
> -> card "MyCardName"
>
>
> Why?
Many of the oddities in the oddities in LiveCode are derived from its
role as a HyperTalk dialect, needing to conform to the conventions of
the Mother Tongue.
In HyperTalk, obtaining "the rect" gives you only the value of the
property you asked for, but asking for "the name" gives you something
more than just the value, prepending the object type to it.
As the others here have noted, this requires you to add something extra
to that property request to get something less: use "the short name" to
get only the value of the name property.
One could argue that there should have been a "type" property for
objects, so if you need to know the type you wouldn't have to ask for a
different property, the name, to know the type.
But alas, the HyperTalk team never asked me, so it is as it is, and
LiveCode has merely followed suit.
There are other legacy anomalies as well, such as being able to use
property syntax to call functions -- that is, sometimes, but sometimes
not, as though the ambiguity is somehow helpful.
For example, you can call the numToChar function using either of these
two forms:
numToChar(128)
the numToChar of 128
Meanwhile, the sum function can only be called using function syntax:
sum(1,2,3) -- works
the sum of "1,2,3" -- throws an error
Why? I can't explain it. It would have been interesting to have been a
fly on the wall in those meetings at Apple where they decided these things.
--
Richard Gaskin
Fourth World
LiveCode training and consulting: http://www.fourthworld.com
Webzine for LiveCode developers: http://www.LiveCodeJournal.com
LiveCode Journal blog: http://LiveCodejournal.com/blog.irv
More information about the use-livecode
mailing list