Hi,
I’m having problem reading back a Property List file I created with “System Events”.
Creation:
set myParentDictionary to make new property list item with properties {kind:record}
— File Object in myPropertyListFile
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
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 on subsequent Runs of the Script I want to restore the properties from the file. I was using the file path, but this is wrong, it need to be the File Object.
—
— 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 it was in a different run of the Script). 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……
Thanks for any help.
All the Best
Dave