tell application "blahBlahApp" in Handler

I want to write some handlers that are specific to one application. They should only be called when inside a tell block to that application. However I can’t control how others might call the handler. Are there any implications that I need to know about having a tell application block inside a handler that is called from a script that already has done tell application “blahblahApp”. What happens if the applications are the same ones, what happens if they are different ones?

Thanks
Kevin

There are no implications or differences between a handler or an ongoing script (also “on run” handler). Any command within a tell block will be targeted to the related app, in despite if it is within a run handler, a user-defined one or whatever.

beep
tell app "Finder"
     kaka() --> error, see explaning
     my kaka()
end tell

to kaka()
     tell app "Safari" to activate
end

The first subroutine call will error, since the Finder doesn’t own any method called “kaka”. To call it properly, use “my”.
Whithin such handler you make a call to Safari. No problemo.
Every command is owned by the current “tell block” scope. If there are not tell blocks, AppleScript is the owner.
And, teorically, osaxen commands can be executed from anywhere.

Thanks for the response. Exactly what I wanted to know.

Kevin

A related problem, so listing it under the same post.
I would like to run a command that is specific to two applications, but the applescript program should run with either one. For example:

tell application “App1”
tell first gps
get cog
end tell
end tell

note that “gps” and “cog” are only defined in App1 or App2.

The application could either be “App1” or “App2”. At runtime, the program will know which one is running, and I put the name of that application into a string variable called “MyRunningApp”. But when I write the script line

tell application MyRunningApp or even tell application quoted form of (MyRunningApp)

I get an error when I compile because the script editor does not know what application I am referring to.

Is there a form of the tell application command that lets the specific application be defined only at runtime?

Thanks