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 can build this structure via Xcode. However, I can't figure out how to build it from Applescript.
Here is the example I put together. First the plist file, test.plist:
<?xml version="1.0" encoding="UTF-8"?> <plist version="1.0"> <array> <array> <string>Array 1 String 1</string> <string>Array 1 String 2</string> <string>Array 1 String 3</string> </array> <array> <string>Array 2 String 1</string> <string>Array 2 String 2</string> <string>Array 2 String 3</string> <string>Array 2 String 4</string> </array> </array> </plist>
Building this in Xcode, I can read it, extract the lists and do what I want with the data.
set DesktopPath to (path to desktop) as text set TestPlist to DesktopPath & "Test.plist" tell application "System Events" to set PlistRecord to value of property list file TestPlist set List1 to item 1 of PlistRecord set List2 to item 2 of PlistRecord
Following Luther's example, to make a new plist file I attempt to initialize it using a shell command. If I use the one in Luther's tutorial, it makes a plist file with a single key referencing a string. I can't replace the record with one that has no key.
So, I need to initialize a plist file that creates that structure. So I tried adding the following:
set PName to quoted form of ((POSIX path of DesktopPath) & "New Test.plist") set cmd to "defaults write " & PName & " '{ { } }'" do shell script cmd tell application "System Events" to set value of property list file PName to PlistRecord
I get an error:
"2013-10-01 08:07:36.529 defaults[29904:f07] Could not parse: { { } }. Try single-quoting it." number 1
First off, it is single-quoted. If I type this command directly into Terminal, I get the same result.
So, my question is, is there a way to initialize, from Applescript, a plist file that is an array of arrays with no key?
TIA,
Jim Brandt |