Hi Folks-
I recently cribbed some code which used the term “my” to call a subroutine, as in:
my subroutine_name
The Applescript Definitive Guide (which finally arrived!) refers to “my” as a synonym for “me”, and to be used as a reference to the current script, and shows calling a handler by merely stating the subroutine name:
subroutine_name
Could someone explain the use of “my”? Thanks!
Ralph
Hi Ralph,
it’s very simple:
my in front of a subroutine is only neccesary, if the subroutine call is within a tell block e.g.
tell app "myApp"
-- do something
my subroutine()
end tell
PS: In Matt Neuburg’s book it’s described on p. 193
On the other hand, my does no harm elsewhere. Whenever you get a message that so-and-so does not understand the “blah()” message, you probably need a “my”.
That makes sense… thanks!
-ralph
When you don’t specify my
or of me
in a tell block, then that application will try to interpret subroutine_name
as one of its own commands (which won’t exist).