Hi Folks,
It seems that after my mac has been running for a few weeks, the following script stops working…
This extract opens the VLC plist file and reads some .plist records.
-- Use System Events to get the core data values of the Recent Document entries in the application's Preferences plist file.
-- They're actually 'alias' data, but are returned here as class 'anything'.
set plistPath to (path to preferences as Unicode text) & bundleID & ".plist"
tell application "System Events"
try
set anythingData to value of property list item "_NSAlias" of property list item "_NSLocator" of property list items of property list item "NSRecentDocumentRecords" of property list file plistPath
on error
set anythingData to {}
end try
end tell
if (anythingData is {}) then
-- No Recent entries to delete.
I can remove the try and System Events complains that it can’t get the item!
Event log:-
get value of property list item "_NSAlias" of property list item "_NSLocator" of every property list item of property list item "NSRecentDocumentRecords" of property list file "Mac HD P1:Users:felicity:Library:Preferences:org.videolan.vlc.plist"
"System Events got an error: Can't get property list item \"_NSAlias\" of property list item \"_NSLocator\" of every property list item of property list item \"NSRecentDocumentRecords\" of property list file \"Mac HD P1:Users:felicity:Library:Preferences:org.videolan.vlc.plist\"."
Property List Editor confirms there are entries there, and so does the application “recent items” menu.
Does system events run out of file handles or something, or not return things in time?
How do I make the script wait…
I have tried a
with timeout of 20 seconds
but that seems to have no effect.
The script seems to work fine shortly after a re-start.
I am starting to think it is real hard to write reliable applescript.
Has anyone else had trouble reading .plist files with applescript system events after the machine has been up for a month or so?
Many thanks
Michael
Model: MacBook Pro 17" Intel
AppleScript: 2.0.1
Browser: Safari 533.19.4
Operating System: Mac OS X (10.5)