• 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: Determining the Default Mail App
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Determining the Default Mail App


  • Subject: Re: Determining the Default Mail App
  • From: kai <email@hidden>
  • Date: Tue, 7 Feb 2006 20:45:02 +0000


On 7 Feb 2006, at 10:43, Mr Tea wrote:

This from kai - dated 7/2/06 00.20:

on defaultApp for i

Got the expected (and correct) results under 10.4.4 here.

Thanks for that, Nick - although, judging from other results, I think the handler is probably looking in the wrong place for the relevant value.


My guess is that, in some cases, the value returned is coincidentally the same as that which should be returned. Other results (for example, from Adam and Todd) appear to expose flaws in the method of extraction. Paul B's outline makes a lot of sense - although I haven't (yet) been able to locate any documentation giving specific details on how launch services works. So at the moment, the only alternative seems to be a number of experiments involving several different machines. While I have a modified version of the handler that promises to work better, it still doesn't go far enough when certain defaults are not specified in the com.apple.LaunchServices.plist file. (While I may have to shelve this for a while, it's an interesting challenge that I hope to return to.) :-)

Thanks to all who provided invaluable feedback on this.

BTW, is using 'for' in this example equivalent to using brackets around the
value being passed to/received by the handler?

Exactly. Either positional or labelled parameters may be passed to a handler.


The more common form, positional parameters, are passed in parentheses:

------------------

to switch_extension(file_name, searchExt, replaceExt)
	tell file_name to if it ends with searchExt then return ¬
		text 1 thru -(1 + (count searchExt)) & replaceExt
	file_name
end switch_extension

switch_extension("some file name.mrw", "mrw", "jpg")

--> "some file name.jpg"

------------------

However, to enhance general sense and readability, labelled parameters can be used instead:

------------------

to switch_extension of file_name from searchExt to replaceExt
	tell file_name to if it ends with searchExt then return ¬
		text 1 thru -(1 + (count searchExt)) & replaceExt
	file_name
end switch_extension

switch_extension of "some file name.mrw" from "mrw" to "jpg"

--> "some file name.jpg"

------------------

While positional parameters must appear in the same order (in both the calling statement and the subroutine), labelled parameters (other than the direct parameter*, if used) may be placed in any order. For example, using the above handler without modification, this calling statement will work equally well:

------------------

switch_extension of "some file name.mrw" to "jpg" from "mrw"

--> "some file name.jpg"

------------------

* The direct parameter in the above example, the variable 'file_name', is indicated by the label 'of' or 'in'. If the direct parameter is included, it must appear first. However, since a direct parameter is not essential (even though I prefer the syntax in this instance), something like this might be used instead:

------------------

to switch_extension for file_name from searchExt to replaceExt
	tell file_name to if it ends with searchExt then return ¬
		text 1 thru -(1 + (count searchExt)) & replaceExt
	file_name
end switch_extension

switch_extension to "jpg" from "mrw" for "some file name.mrw"

--> "some file name.jpg"

------------------

Besides the direct parameter label (of/in), a boolean parameter (with/ without) and the special label 'given', the only terms that may be used as parameter labels are:

------------------

about
above
against
apart from
around
aside from
at
below
beneath
beside
between
by
for
from
instead of
into
on
onto
out of
over
thru
to
under

------------------

(As with record labels, each parameter label can be used only once for a particular subroutine.)

For more information:
---------------------

Subroutines With Labeled Parameters:
http://developer.apple.com/documentation/AppleScript/Conceptual/ AppleScriptLangGuide/AppleScript.d8.html


Subroutines With Positional Parameters:
http://developer.apple.com/documentation/AppleScript/Conceptual/ AppleScriptLangGuide/AppleScript.dc.html


---------------------

PS: Whatever became of "Brew of the day", Nick? ;-)

---
kai


_______________________________________________ Do not post admin requests to the list. They will be ignored. Applescript-users mailing list (email@hidden) Help/Unsubscribe/Update your Subscription: This email sent to email@hidden
  • Follow-Ups:
    • Re: Determining the Default Mail App
      • From: Mr Tea <email@hidden>
    • Re: Determining the Default Mail App
      • From: Adam Bell <email@hidden>
References: 
 >Re: Determining the Default Mail App (From: Mr Tea <email@hidden>)

  • Prev by Date: Odd question
  • Next by Date: Re: Determining the Default Mail App
  • Previous by thread: Re: Determining the Default Mail App
  • Next by thread: Re: Determining the Default Mail App
  • Index(es):
    • Date
    • Thread