Re: System Events - Property Lists


Dave
 

Ok, I now think it IS because I don’t have a Property List File Object,

Creation:

set myParentDictionary to make new property list item with properties {kind:record}

— File Object in 
set myPropertyListFile to make new property list file with properties {contents:myParentDictionary, name:pMWLPrefsFilePOSIXPath of me}

tell application "System Events"
tell property list file pPrefsFileObject of me
set pModOrderFileURL of me to value of property list item "pModOrderFileURL"
set pModOrderList of me to value of property list item "pModOrderList"
set pModInfoList of me to value of property list item "pModInfoList"
end tell
end tell

—Test Reading Back here, works ok
tell property list file myPropertyListFile of me
set pModOrderFileURL of me to (value of property list item "pModOrderFileURL")
set pModOrderList of me to value of property list item "pModOrderList"
set pModInfoList of me to value of property list item "pModInfoList"
end tell


It does this if it doesn’t find a prefs file, to create one.

Then of subsequent Run of the Script I want to restore them:

—  This doesn’t work since I’m passing the File Path String instead of a File Object
--
tell application "System Events"
tell property list file pMWLPrefsFilePOSIXPath of me
set pModOrderFileURL of me to (value of property list item "pModOrderFileURL")
set pModOrderList of me to value of property list item "pModOrderList"
set pModInfoList of me to value of property list item "pModInfoList"
end tell
end tell

But I don’t have the File Object that was around (myPropertyListFile) when it was created. So, given the file on the disk, how to I get a new a File Object? 

I am assuming you can read back the file?!?!? It doesn’t actually say you can, it would be typical of Apple to give you something to write a property list but not give you one to read it back again, and when it comes to AppleScript it wouldn’t surprise me in the least.

Fed up with poor documentation…..

All the Best
Dave

















Join applescript@apple-dev.groups.io to automatically receive all group messages.