In a tell block which references a specific application I want to use some handlers to manipulate the application’s objects and also external objects which might be needed, such as AppleScript’s text delimiters. Will the handler commands recognize application objects without a tell statement referencing the application explicitly? What’s the right way to do this?
Each handler must contain ‘tell’ statements for any application used in it. A call to a handler from within a ‘tell’ block must be preceded by ‘my’ to identify the handler as something belonging to the script and not to the application. You don’t need to make any special provisions for passing application objects as parameters.
tell application "My App"
-- Blah blah.
my subroutine(param)
-- Blah blah
end tell
on subroutine(param)
tell application "My App"
-- etc.
end tell
end subroutine
Thanks for reply. Clears things up for me. I had not understood too well the use of “my.” In scripting an AS application with a handler definition one could actually have something like this, where calculateF is defined (possibly differently) in both the AS application and the script (?):
------------script----------
tell application “theASapp”
my calculateF(calculateF(X,Y),Z)
(*
or alternatively
set Y to calculateF(X,Y)
my calculateF(Y,Z)
*)
end tell
on calculate(Y,Z)
–do something
end calculate
-----------end script---------
Thanks. Now I know why I got so many inexplicable errors, particularly those “unable to coerce” errors that have occurred apparently in defiance of common sense but not logic.