Weirdness Passing Messages

Mark Smith mark at maseurope.net
Thu Mar 23 06:56:58 EST 2006


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

On 23 Mar 2006, at 11:21, David Burgun wrote:

> Update:
>
> I just changed the code so that instead of:
>
> put "MessageY" into me
>
> It now reads:
>
> put "MessageY" into field "FieldY" of group "Y" of card 2 of stack  
> "/Documents/Test/StackMain.rev"
>
> And now the "put" statement works as expected!!!!!!!
>
> Can anyone shed some light on this?
>
> I really need to refer to the object without hardcoding it's name  
> into the Script, I thought that was what "me" was for?????
>
> Is this a bug? If so is there a workaround??
>
> Thanks a lot
> All the Best
> Dave
>
> Hi,
>
> As far as I know (I have asked this question on this list before)  
> and according to the documentation, "me" always refers to the  
> object that the script is running in.
>
> Are you suggesting I change "me" to "long name of x" just to see if  
> it makes a difference or in general?
>
> If you mean in general, then this will mean that a lot of the  
> reusability of code that is so good in RunRev will vanish and make  
> developing Apps MUCH slower. In fact if I have to do this then I  
> would seriously consider not using RunRev anymore.
>
> I have lots of fields that all refer to "me", to change them now  
> would take forever and result in a lot of hand-tweaking every time  
> I want to re-use a Group.
>
> Here is the problem again, described in simpler terms:
>
> 1  StackMain:Card1:ObjectA:mouseUp   - Calls Function  
> StackUtil:PutMessage("MessageX")
> 2  StackUtil:PutMessage                             - Calls Handler  
> StackMain:Card2:ObjectX:MessageX (via send)
> 3  StackMain:Card2:ObjectX:MessageX - Put "MessageX" into me and  
> then Calls Function StackUtil:PutMessage("MessageY")
> 4  StackUtil:PutMessage                            - Calls Handler  
> StackMain:Card2:ObjectY:MessageY (via send)
> 5  StackMain:Card2:ObjectY:MessageY - Put "MessageY" into me
>
> In this case the "put" statement at step 5 does NOT put "MessageY"  
> into  StackMain:Card2:ObjectY (the object is unchanged), but the  
> "put" at step 3 works ok.
>
> However, this does work:
>
> 1  StackMain:Card2:ObjectX:mouseUp   - Calls Function  
> StackUtil:PutMessage("MessageY")
> 2  StackUtil:PutMessage                             - Calls Handler  
> StackMain:Card2:ObjectY:MessageY (via send)
> 3  StackMain:Card2:ObjectY:MessageY - Put "MessageY" into me
>
> What could be going wrong here? Is it that I am mixing functions  
> and handlers?
>
> How can I test to see if the context is the problem?
>
> Any ideas on how to get this working would be greatly appreciated.
>
> Thanks a lot
> All the Best
> Dave
>
> On 23 Mar 2006, at 02:22, Mark Smith wrote:
>
>> Is it a context problem?
>>
>> It might be worth trying to replace
>> put "MessageY" into me
>> with
>> put "MessageY" into <long name of control>
>>
>> I've always thought that 'me' always referred to the control whose  
>> script it appears in, but that's an assumption, not  necessarily a  
>> fact...
>>
>> Mark
> _______________________________________________
> use-revolution mailing list
> use-revolution at lists.runrev.com
> Please visit this url to subscribe, unsubscribe and manage your  
> subscription preferences:
> http://lists.runrev.com/mailman/listinfo/use-revolution




More information about the use-livecode mailing list