Re: Creating A Property List File
Re: Creating A Property List File
- Subject: Re: Creating A Property List File
- From: Luther Fuller <email@hidden>
- Date: Wed, 19 Mar 2008 08:05:43 -0500
On Mar 18, 2008, at 9:40 PM, Andy Boretto wrote:
why not just do this
do shell script "defaults write com.myplist.thelist theKey theValue"
log (do shell script "defaults read com.myplist.thelist theKey")
This make a plist for you, in ~/Library/Preferences/, to write into.
no need for all of that code.
And
On Mar 19, 2008, at 4:50 AM, Skeeve wrote:
Luther Fuller wrote:
I haven't used an osax in years. (Many!) I can usually work-around
with AppleScript or a command that is a standard install on
anyone's Mac.
Same for me. BTW: Why not create an XML property list and simply
write out the XML text?
The handler I wrote does more than just create an almost empty .plist
file in some default location. I probably should have written it with
these input parameters ...
on makeNewPlist(newFileLoc, fileName, initialRecord)
but, I also had that little problem with an empty dictionary. Your
variant may vary.
The man page for 'defaults' makes the initial data look easy (...
theKey theValue), but translating a perhaps complicated initial
record into text so you can use it in 'do shell script' is even more
complicated. Translating an AppleScript record into "Property List
XML" text is do-able, I guess, but why bother? If the initial record
has even a bit of complication in its structure, the code would
become a series of 'do shell script "defaults ..."' each adding to
the initial data.
System Events knows how to translate between records in AppleScript
and "Property List XML", so I let System Events do that hard work. I
simply set the value of the PLFile to a record or set a record to the
value of the PLFile. "Property List XML" isn't as general as XML, but
it's very useful. When you open a .plist file with Property List
Editor, simply don't touch that "Dump" button and you will never see
any confusing xml text.
_______________________________________________
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