Looking for a simple AppleScript example of creating an array of string items (i.e. Item 0, Item 1, ... Item n) in a new plist file. Only have found an example of how to read an array item in an existing plist file and not the initial creation of the array of strings itself in a new property list. Appreciate the assistance.
AppleScript Plist array of items creation example?
The easiest would probably be to use some AppleScriptObjC (System Events gets a bit convoluted), for example:
use framework "Foundation"
use scripting additions
set testRecord to {SomeText:"this is some text", SomeNumber:42, SomeBoolean:false, SomeList:{"zero", "one", 2, 3, 4.0, 0.5}, SomeDict:{AnotherList:{"another 1", "another 2", 3}}}
set testList to {"test item 0", "test item 1", "test item 2"}
makePlist for testList at (choose file name default name "Untitled.plist")
to makePlist for plistItem at filePath -- write a record/list to an XML property list file
set filePath to POSIX path of (filePath as text)
set plistData to current application's NSPropertyListSerialization's dataWithPropertyList:plistItem format:(current application's NSPropertyListXMLFormat_v1_0) options:0 |error|:(missing value)
return (plistData's writeToFile:filePath atomically:true) as boolean -- success?
end makePlist