put into named field weirdness
J. Landman Gay
jacque at hyperactivesw.com
Mon Feb 11 16:31:43 CST 2008
Russell Martin wrote:
> Wow. Thank you.
> That was completely counterintuitive, but, you are 100% correct.
It might be more intuitive if you think of "this" as refering to the
stack that currently has the engine's attention. The dictionary says
that any object reference that has no stack reference in it is assumed
to be in the defaultstack. It gives the example of "this card", which
the engine interprets as "this card of the defaultstack". (See
"defaultstack" in the dictionary.)
> So, is there another way to refer to the stack that the currently
> executing script belongs too? One that remains constant? Maybe
> something like 'target owner'?
Not specifically. There is the keyword "me" which refers to the object
running the script. If your script is in the stack script, then "me" is
the stack. But if the script is in another object, then it is that
object which is "me", not the stack itself. Since your handlers seem to
be in a stack script you could get away with using "me" as long as you
remain aware that moving the handlers will break them.
If the script is in a card you can sometimes use "the owner of me",
which will often be the stack. But it isn't 100% reliable; for example,
if the card is part of a background group, then its owner is the group.
Depending on what you're doing, there are lots of workarounds. It is
common to store the name of the stack at the beginning of a handler so
that you can reference it later on as needed. If you do that a lot, you
can write a short function that will always return the stack name. Or if
you need something else, let us know and someone will no doubt jump in.
There are a lot of ways to skin that cat.
Jacqueline Landman Gay | jacque at hyperactivesw.com
HyperActive Software | http://www.hyperactivesw.com
More information about the use-livecode