Re: read a plist
Re: read a plist
- Subject: Re: read a plist
- From: Christopher Nebel <email@hidden>
- Date: Tue, 15 Jan 2008 12:56:24 -0800
On Jan 15, 2008, at 12:07 PM, KOENIG Yvan wrote:
I have an HFS path to a plist file :
set thePlist to "Macintosh
HD:Users:yvankoenig:Library:Preferences:com.apple.iWork.Numbers.plist"
How may I use it to read a value in the plist file?
I tried:
set thePlist to "Macintosh
HD:Users:yvankoenig:Library:Preferences:com.apple.iWork.Numbers.plist"
set thePlist to POSIX file thePlist
tell application "System Events"
tell contents of property list file thePlist
{value of property list item "LSDocumentDefaultSaveDirectory"}
end tell
end tell
but it fails.
I checked that if I define
set thePlist to "~/Library/Preferences/com.apple.iWork.Numbers.plist"
It works but how may I convert flawlessly the original path to a
usable one?
Easy. Don't do anything. Just remove the "set thePlist to POSIX file
thePlist" line and it'll be fine.
Longer explanation: The "POSIX file" class lets you turn a POSIX path
string into a "file" object (or at least something that's usable as
one.) It is *not* to be used with an HFS path string. Besides,
System Events' various file classes will happily accept either an HFS
path string or a POSIX path string as their "name", so no conversion
is even needed.
--Chris Nebel
AppleScript Engineering
_______________________________________________
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
References: | |
| >read a plist (From: KOENIG Yvan <email@hidden>) |