Last active
August 29, 2015 14:13
-
-
Save miyagawa/a70892a0b0ca2f570ae2 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- 1. TextEdit got an error: Can’t get POSIX file "..." | |
set p to "/path/to/file.txt" | |
tell application "TextEdit" | |
set q to POSIX file p | |
end tell | |
-- 2. This works | |
tell application "TextEdit" | |
set q to POSIX file "/path/to/file.txt" | |
end tell | |
-- 3. This works | |
set p to "/path/to/file.txt" | |
tell application "TextEdit" | |
set q to (p as POSIX file) | |
end tell | |
-- 4. This works | |
set p to "/path/to/file.txt" | |
set q to POSIX file p |
Yeah I got the lesson out of this - the thing that drives me nuts is that it sometimes works and sometimes doesn't!
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
posix file belongs to standard additions. When possible, don't include it in a tell block.
set p to "/path/to/file.txt"
set q to POSIX file p
tell application "TextEdit" to open q