• 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
Re: How can I open attachment in Mail ?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: How can I open attachment in Mail ?


  • Subject: Re: How can I open attachment in Mail ?
  • From: kai <email@hidden>
  • Date: Wed, 25 Oct 2006 01:10:32 +0100


On 24 Oct 2006, at 08:35, Philip Aker wrote:

On 2006-10-23, at 10:53:10, kai wrote:

do shell script "echo 'puts [file nativename [exec defaults read com.apple.mail MailDownloadsPath]]/' | tclsh"

Shorter, certainly (as one might expect from an all-shell approach) - though not necessarily faster. (The original executes approximately 2.5 times faster here.) Adopting a slightly more verbose form, to avoid the shell altogether, yields an even greater performance boost (about 5 times faster than the one-liner):

I agree that in general, it's much better to stick to the same language if possible.


But it's unfair to compare timings for mixed call scripts in Script Editor. The test in that case is to run them a 1000 times in Terminal via osascript/tclsh/perl/pythonw/ruby because then the load factors while not equal, are on more of an even footing. For instance if I was to run the same solution favoring the Tcl calls in a Tk application, or a stay open TclOSA applet then the Tcl binary would already be loaded and its alien load factors would be that of TclAppleScript/ascr and maybe 'defaults'. Similarly for Perl, Python, and Ruby environments with their AppleScript or appscript solutions.

The fairest test would surely be that which most closely simulates the conditions under which the script will ultimately be run. If the intention is to eventually use it in terminal, via whatever, then testing in that environment would make sense. However, since the original script was explicitly intended to be invoked from a Mail "Run AppleScript" rule, the comparison that I used seems (to me, at any rate) fair enough.


Anyway, my indirect point was that AppleScript ought to be able to do tilde expansion on a POSIX file cast.

POSIX file "~/Desktop/some.txt"
--> file ":~:Desktop:some.txt"

I'd clean forgotten about the system attribute thing (thanks, Chris) - which allows a further bump of about 10-20%:


------------------
on download_path()
set p to (path to preferences folder from user domain ¬
as Unicode text) & "com.apple.mail.plist"
tell application "System Events" to set f to value of ¬
property list item "MailDownloadsPath" of property list file p & "/"
if f starts with "~" then return (system attribute "HOME") & f's text 2 thru -1
f
end download_path
------------------


---
kai


_______________________________________________ Do not post admin requests to the list. They will be ignored. AppleScript-Users mailing list (email@hidden) Help/Unsubscribe/Update your Subscription: Archives: http://lists.apple.com/mailman//archives/applescript-users

This email sent to email@hidden
  • Follow-Ups:
    • Re: How can I open attachment in Mail ?
      • From: Philip Aker <email@hidden>
References: 
 >How can I open attachment in Mail ? (From: Victor Frenklakh <email@hidden>)
 >Re: How can I open attachment in Mail ? (From: kai <email@hidden>)
 >Re: How can I open attachment in Mail ? (From: Philip Aker <email@hidden>)
 >Re: How can I open attachment in Mail ? (From: kai <email@hidden>)
 >Re: How can I open attachment in Mail ? (From: Philip Aker <email@hidden>)

  • Prev by Date: Re: Importing/parsing CSV files
  • Next by Date: Re: "~" vs. "POSIX file"
  • Previous by thread: Re: "~" vs. "POSIX file"
  • Next by thread: Re: How can I open attachment in Mail ?
  • Index(es):
    • Date
    • Thread