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.
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.
-------------------------------------------------------------------------------------------
The code works and yet produces an error.
I continue to prefer to keep the Finder and POSIX Paths widely separate.
The Finder likes aliases, HFS paths, and FURLs («class furl»). When I stick to those I rarely have any problems.
Since System Events is better behaved these days and understands $HOME-based POSIX Paths, I don't mind using it in an alias-from-path-string handler:
------------------------------------------------------------------------------------------- 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 -------------------------------------------------------------------------------------------
|