Inside a handler (or if you prefer, "method" of a parent script or behavior script), you need to have the "me" in two circumstances:

1) if you have any other parameters. This is because methods expect to see the current instance of the object as the first parameter (this is really what "me" is), then the next thing is the real first parameter. So if you had a method like this:

on mMyMethod me, param1, param2, ...

and a call like this:

someObjectReference.mMyMethod(var1, var2, ...)

The value of someObjectReference is passed into the handler and is given to the variable "me". The value of var1 is given to param1, v2 is given to param2, etc. So, bottomline, if you are passing in any more variables, you need to have "me" to catch the object reference.

2) if you are going to call any other method in the same script. You will need "me" here if you want to call some other method since you need to pass the object reference along, for example:

on myMethod1 me
   ... some code
   me.myMethod2(<any or no parameters>)
   ... some code
end

on myMethod2 me
  ... some code
end

Since myMethod2 is a method of a script, it must have an object reference just like myMethod1. When calling myMethod2, you must use "me." to tell it which instance. If you didn't have "me" in the definition of myMethod1, then you would get a compilation error on the call to myMethod2, because "me" is undefined.

Consider yourself enlightened about your baxic question.

All that being said, I always add "me" to all methods. It's just easier to remember to do it all the time, rather than trying to figure out when it is not needed.

Also, while "x" is very short and will save typing, I would never use such a name. Over time, you (or more correctly, I) would forget what the method does if it didn't have a descriptive name. :)

Irv


At 9:36 PM +0200 8/5/04, Michael von Aichberger wrote:
Hi everybody,

I have a baxic question about parent scripts.

Until now, a typical handler definition in a parent script of mine looked
like

on mWhatToDo me
...
end


and it was run like that:

me.mWhatToDo()


Now I have a handler that is called very often so that it would be nice, if the handler name were very short. As short as possible that is.

This could be:

on x me
...
end

which could be run with

me.x()



Next I was asking myself, if the "me" could be omitted.

I tried

on x
end

and called it with:

x()

And it worked!

However I am sure there must be something wrong with it. There must be a
reason for the "me" after all.

Can anybody enlighten me?

Thanks!

Michael




[To remove yourself from this list, or to change to digest mode, go to http://www.penworks.com/lingo-l.cgi To post messages to the list, email [EMAIL PROTECTED] (Problems, email [EMAIL PROTECTED]). Lingo-L is for learning and helping with programming Lingo. Thanks!]


--

Multimedia Wrangler.
[To remove yourself from this list, or to change to digest mode, go to 
http://www.penworks.com/lingo-l.cgi  To post messages to the list, email [EMAIL 
PROTECTED]  (Problems, email [EMAIL PROTECTED]). Lingo-L is for learning and helping 
with programming Lingo.  Thanks!]

Reply via email to