Weirdness Passing Messages

David Burgun dburgun at dsl.pipex.com
Thu Mar 23 07:34:22 EST 2006


Hi Mark,

I looked at the information you pasted below too, don't worry! It's  
the document that is "foggy" not you! I've read and re-read it over  
and over again and I am not 100% sure of what is "supposed" to happen  
either!

I change the "me" to "the target" and it still doesn't work!

One thing I did was to add the following to ObjectY:MessageY:

put the long name of me & cr & the long name of the target

To dump the names to the the message box, they are Identical so it's  
not surprising it doesn't work either!

I also played with this:

  put the long name of me into myLongName
  put "MessageY" into myLongName

However, this just assigns "MessageY" to myLongName!

Do you know how I can force it to use the contents of myLongName as a  
field reference?

Thanks a lot
All the Best
Dave

On 23 Mar 2006, at 12:23, Mark Smith wrote:

> Scratch that - sorry, I'd left the 'go cd' line in...taking it  
> out,  using 'the target' also fails.
>
> So, to narrow down the problem,
>
> I made a mainstack - stack "mp" with 2 cards. On card 2 there is a  
> field "f1" with the script
>
> on showMessage tm
>   beep
>   put tm into me
> end show message
>
> I then made a substack - stack "mps", with a button, whose script is
>
> on mouseUp
>   put "hello" into tm
>   send "showMessage tm" to fld "f1" of cd 2 of stack "mp"
> end mouseUp
>
> Now, if cd 2 of stack "mp" is the current cd of stack "mp", on  
> clicking the button in stack "mps", I hear a beep, and the word  
> 'hello' appears in fld "f1". So far so good.
>
> However, if cd 1 is the current card of stack "mp", on clicking the  
> button in stack "mps", I hear a beep. I then go to cd 2 of stack  
> "mp", and fld "f1" is empty...
>
> Inserting "put tm" into the showMessage handler in fld "f1", I  
> click, and "hello" appears in the message box, so the parameter is  
> certainly getting there. Then inserting "put the target" into the  
> showMessage handler, I click, and "field "f1"" appears in the  
> message box, but still fld "f1" is empty.
>
> I'm baffled.
>
> Mark
>
>
> On 23 Mar 2006, at 11:56, Mark Smith wrote:
>
>> I just set up a slightly simpler version of what you've described,  
>> and got exactly the same results. I then inserted 'go cd 2 of  
>> stack "stackMain" into then putMessage handler, just before the  
>> 'send to' line, and it works as desired,
>> so it's definitely a context problem. Checking the docs:
>> -----
>> If the currently executing handler is in the script of the object  
>> that received the original message, then me is the same as the  
>> object whose name is returned by the target function. For example,  
>> suppose a button script contains a mouseDown handler. The value of  
>> the target function within that mouseDown handler is the same as  
>> the name of me: the name of the button.
>>
>> However, if the mouseDown handler is in the card's script instead  
>> of the button's, me is not the same as the object specified by the  
>> target. In this case, me is the card, but the target function  
>> returns the button's name, because the button is the object that  
>> first received the mouseDown message.
>> ----
>>
>> which to my slightly foggy mind suggests that when explicitly  
>> 'send' ing a message to an object from another object (overiding  
>> the message path) it might be necessary to use 'the target' rather  
>> than 'me'..
>>
>> so now I've substituted "the target" for "me" in the objects  
>> script, and the problem seems to be solved. Does that work for you?
>>
>> Mark




More information about the use-livecode mailing list