On Oct 1, 2013, at 8:17 AM, Jim Brandt wrote: I have a question about initializing a plist file. Specifically, a plist file tahe is an array of arrays (list of lists).
I have read Luther Fuller's "Property List Tutorial". I have built plist files that have a single key that references a list of lists. What I want to do is eliminate the key and make a plist whose record structure is a list of lists with no key.
I haven't looked at my "Property List Tutorial" in awhile. It's currently dated Feb 2011. And it's still in draft. I will finish it and post it somewhere if anyone can recommend a site.
I did check one of my applications that creates a .plist preference file and found this handler ...
on makeNewPlistFile(folderAlias, filename, initialRecord) try return ((folderAlias as text) & filename & ".plist") as alias -- the file already exists end try set newFileName to (folderAlias as text) & filename tell application "System Events" make new property list item with properties {kind:record, value:initialRecord} make new property list file with properties {contents:the result, name:newFileName} set newFileName to (path of the result) end tell return (newFileName as alias) end makeNewPlistFile --------------------------------------------------------------------
This is more or less the same thing Shane Stanley is doing in his response.
The code for changing the content of the .plist file is super simple … Just write a new AppleScript record to the file. For example …
tell application "System Events" to set value of property list file (prefsFile as text) to prefsRec
(where 'prefsFile' is an alias to a .plist file.) In this code 'prefsRec' is any AppleScript record. You don't need xml. You do need to know how to concatenate records and how AppleScript's data types differ from .plist data types.
|