• 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: trivial Finder path problem
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: trivial Finder path problem


  • Subject: Re: trivial Finder path problem
  • From: Yvan KOENIG <email@hidden>
  • Date: Sun, 11 Dec 2016 11:06:14 +0100


Le 10 déc. 2016 à 22:37, Christopher Stone <email@hidden> a écrit :

On Dec 10, 2016, at 07:47, Yvan KOENIG <email@hidden> wrote:
but
tell application "Finder" to get (POSIX file ("/System/Library/Fonts/" & "Menlo.ttc")) as alias  behaves flawlessly.


Hey Yvan,

Thanks.  I'd forgotten that little gimmick.

Running in the Script Editor with the Log History window open I get:

-------------------------------------------------------------------------------------------
tell application "Finder"
    get POSIX file "/System/Library/Fonts/Menlo.ttc"
       --> error number -1728 from POSIX file "/System/Library/Fonts/Menlo.ttc"
end tell

Result:

alias "Mercury:System:Library:Fonts:Menlo.ttc"
-------------------------------------------------------------------------------------------

-1728 → The referenced object doesn’t exist. This is a run-time resolution error, such as when attempting to reference a third object when only two objects exist.


You get - me too - the non fatal error issued each time we use an OSAX feature in a tell application block.
POSIX file ("/System/Library/Fonts/" & "Menlo.ttc")
tell application "Finder" to result as alias
get rid of this non fatal error.


-------------------------------------------------------------------------------------------
set thePath to "~/Downloads" -- $HOME-based POSIX Path.
set myAlias1 to makeAliasFromPathString(thePath)

set thePath to "/Users/chris/Downloads" -- POSIX Path
set myAlias2 to makeAliasFromPathString(thePath)

set thePath to (path to downloads folder as text) -- HFS Path
set myAlias3 to makeAliasFromPathString(thePath)

on makeAliasFromPathString(thePath) -- Input: POSIX-Path, Tilde-Path, or HFS-Path
    tell application "System Events" to set thePath to POSIX path of disk item thePath
    return (POSIX file thePath) as alias
end makeAliasFromPathString
-------------------------------------------------------------------------------------------

In fact, the handler is only needed for $HOME based path

set thePath to "/Users/chris/Downloads" -- POSIX Path
set myAlias2 to (POSIX file thePath) as alias

set thePath to (path to downloads folder as text) -- HFS Path
set myAlias3 to thePath as alias
or shorter and more efficient
set myAlias3 to path to downloads folder -- which is an alias


Yvan KOENIG running Sierra 10.12.1 in French (VALLAURIS, France) dimanche 11 décembre 2016 11:05:57



 _______________________________________________
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/archives/applescript-users

This email sent to email@hidden

  • Follow-Ups:
    • Re: trivial Finder path problem
      • From: Christopher Stone <email@hidden>
References: 
 >Re : trivial Finder path problem (From: Yvan KOENIG <email@hidden>)
 >Re: trivial Finder path problem (From: Christopher Stone <email@hidden>)

  • Prev by Date: Apple script command help please
  • Next by Date: Re: Apple script command help please
  • Previous by thread: Re: trivial Finder path problem
  • Next by thread: Re: trivial Finder path problem
  • Index(es):
    • Date
    • Thread