Very Very Very Basic Question!!!!!
ambassador at fourthworld.com
Thu Mar 23 12:12:36 EST 2006
David Burgun wrote:
> Should the following lines work 100% of the time, regardless of how
> or where the message handler is called?
> on MessageHandler
> local myData
> set the text of the long name of me to "XXXXX"
> put the text of the long name of me into myData
> end MessageHandler
Works here like this:
Stack "A" is a mainstack, and stack "B" is a substack of "A". "B" has
two cards, the second card has a field with the script above in it.
Stack "A" has a button with this script:
send "MessageHandler" to fld "x" of cd 2 of stack "b"
If I go to cd 1 of stack "B" and then click the button in stack "A",
when I go back to cd 2 of stack "B" I get "XXXXX" in the field.
Interestingly, if I change the script in the field to this:
set the text of me to "XXXXX"
I then reverted the script to the form that works, went to card 1 of
"B", saved "B", then closed it, and then clicked the button in stack "A"
again -- opening "B" again and looking at cd 2 showed "XXXXX" in the
field. This may be useful since it confirms that you can trigger
messages and alter properties in stacks that aren't officially open, as
long as their destroyStack property is false.
So the rule is that as long as you coerce object references derived from
"me" to the long ID you'll be fine. In other cases "me" will work as
expected, but for the reasons outlined in my earlier lengthy post not
always (thanks, HyperCard team).
As for the second line, since myData is declared locally what do you
want to do with it? It's scope suggests that nothing is done with it,
since it's declared inside the handler and the handler doesn't do
anything with it before it exits.
Managing Editor, revJournal
Rev tips, tutorials and more: http://www.revJournal.com
More information about the Use-livecode