System Events - Property Lists


Dave
 

Hi All,

I have a question about the System Events Property List Suite.

I have code to setup a property list file and it seems to work ok.

It creates it and sets it to the initial values:

set myParentDictionary to make new property list item with properties {kind:record}
set myPropertyListFile to make new property list file with properties {contents:myParentDictionary, name:pMWLPrefsFilePOSIXPath of me}
tell property list items of myPropertyListFile
make new property list item at end with properties {kind:string, name:"pModOrderFileURL", value:pModOrderFileURL of me}
make new property list item at end with properties {kind:list, name:"pModOrderList", value:pModOrderList of me}
make new property list item at end with properties {kind:list, name:"pModInfoList", value:pModInfoList of me}
end tell

To update values to:

on SetPersistentValue(thePropertyName, theValue)
tell application "System Events"
tell property list file (pMWLPrefsFilePOSIXPath of me)
set value of property list item thePropertyName to theValue
end tell
end tell
end SetPersistentValue

This all work ok (or seems to), however when I come to restore the values:

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

I get an error:

value of property list item "pModOrderFileURL" of property list file "/Users/surfacedetail/Documents/MWL/MWLPrefs/MWLPrefs.plist”.

I’m guessing its because it expects a Property List File Object, not a Path String, however I’m at a loss as to know how to get this object, when it was created I was making a new file, but now I want to reference the same file, bet I can’t find a way of objecting the Object for an existing plist file.

Any help greatly appreciated.

All the Best
Dave

















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