• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Scripting Additions Calls in Tell Blocks
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Scripting Additions Calls in Tell Blocks


  • Subject: Scripting Additions Calls in Tell Blocks
  • From: Michael Terry <email@hidden>
  • Date: Mon, 9 Feb 2004 16:34:18 -0800

There was a thread recently, that I can't find, in which calling scripting additions within application tell blocks was discussed. This issue comes up from time to time, I guess. It used to be settled law that one avoided doing it, partly because of efficiency issues. It was thought that the command had to pass through the tell block's application before reaching the applescript component where it was handled.

Recently it's been claimed, I think, that this is a myth. I don't know if it is supposed to ever have been true. I've always called additions outside of app tells mostly for style reasons--every command has a target, and it's wrong somehow to imply that your target is the tell block's application.

However, now it seems to me that calling additions in tell blocks isn't as harmless has been made out. I didn't know that scripting additions could be aware of their context, but note:

<><><><><><><><><><><><><><><><><><><><><><<><><><><><><><><><><><><><>< ><><><>

------------------------------------------------------------------------ ---
-- i set system browser default to Safari (in Safari prefs) before running
------------------------------------------------------------------------ ---
open location "http://www.google.com/";
--> ".014 secs"

tell application "Safari"
open location "http://www.google.com/";
end tell
--> ".405 secs"

------------------------------------------------------------------------ ---
-- note that if Safari already has a window with the url open, calling open
-- location inside a Safari tell block just makes sure that said window
-- is in front
------------------------------------------------------------------------ ---
tell application "Safari"
open location "http://www.google.com/";
end tell
--> ".031 secs"
-- even this is slower!

<><><><><><><><><><><><><><><><><><><><><><<><><><><><><><><><><><><><>< ><><><>

I used a timer which depended on the GetMilliSec osax, because I couldn't think of an easy way to illustrate the cases with plain AS.

Now, I happen to think 'open location''s behavior is wonderful, but what I'm claiming is, unless you specifically need a special effect, you should normally not execute addition commands in app tell blocks. Sometimes it doesn't make any difference, but sometimes it does.


Mike
_______________________________________________
applescript-users mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/applescript-users
Do not post admin requests to the list. They will be ignored.

  • Follow-Ups:
    • Re: Scripting Additions Calls in Tell Blocks
      • From: Gary Lists <email@hidden>
    • Re: Scripting Additions Calls in Tell Blocks
      • From: Graff <email@hidden>
    • Re: Scripting Additions Calls in Tell Blocks
      • From: Michael Terry <email@hidden>
    • Re: Scripting Additions Calls in Tell Blocks
      • From: Shane Stanley <email@hidden>
  • Prev by Date: Something to watch out for...
  • Next by Date: Re: Scripting Additions Calls in Tell Blocks
  • Previous by thread: Re: Something to watch out for...
  • Next by thread: Re: Scripting Additions Calls in Tell Blocks
  • Index(es):
    • Date
    • Thread