Weirdness Passing Messages

David Burgun dburgun at dsl.pipex.com
Fri Mar 24 11:43:43 EST 2006


On 24 Mar 2006, at 16:12, J. Landman Gay wrote:

> David Burgun wrote:
>
>> Incidentally, the above works  just fine regardless of the stack/ 
>> card/ object using "put <something> into me". The problem I  
>> described  yesterday was brought to light because when a new  
>> folder is selected,  I wanted to select the first line (file) in  
>> the list, so inside  ISM_FolderSelect(), I did a ISMPutMessage 
>> ("ISM_FileSelected,  kFileKind, line 1 of me), when this happened,  
>> "me" in the receiving  handler got Beswick'ed!
>
> Which is reasonable, I think. Think about this a moment --  
> parameters are always evaluated before being passed. When you pass  
> "me" in a parameter, the "me" will refer to the object currently  
> executing the script, not the target object the script will  
> eventually refer to later. This is normal behavior.

This was just short hand to explain how I came to find the bug. What  
I was trying to point out is that the problem was triggered by me  
calling a handler in an unopened card from an object inside the same  
(unopened card).

The actual code is:

put line 1 of the text of me into myFileName
get ISMPutMessage(ISM_FileSelected,  kFileKind, myFileName)

The problem was in the ISM_FIleSelected handler in the *destination"  
object. Which did this:


on ISM_PutMessage( heMessageID,theSubCode,theFilePathName)
--
--  Other code
--

put <something>  into me  --<something> being based on the file name.

--
--  Other code
--
end ISM_PutMessage

> Take this example:
>
>   addNums (1+1)
>
> The addNums handler will receive a parameter of "2", not "1+1".  
> Ditto for "me", which will be interpreted as the object *currently*  
> running the script, not the future target of the handler reference.

I don't pass "me" as a parameter for the very reason you mention. The  
problem is in the destination handler which is a different "me"!!!!!
>
> When passing a reference parameter, use an ID or other static  
> reference, not "me" which is always subject to interpretation. As  
> you found out. ;)

>
> If you absolutely must use "me" then you can try putting the  
> parameter in quotes to force it into acting as a string. Strings  
> won't be evaluated. I don't know if this will work in your  
> situation but you can try it.
>
> Now that I understand your usage better, I do not think this is a bug.

The bug is that:

put <something> into me

or

set the text of me to <something>

Doesn't work 100% of the time. Sorry for the confusion, I didn't mean  
you to take the pseudo code I posted literally. I have found the bug  
now and changed the offending lines to:

set the text of the long is of me to <something> and it works fine now.

Thanks a lot
All the Best
Dave









More information about the use-livecode mailing list