on PersistentVariables()
prepare storage for (path to me) ¬
default values {itemsToVersion:{}} ¬
without write lock
set my itemsToVersion to value for key "itemsToVersion"
end PersistentVariables
on SavePersistentValues()
assign value itemsToVersion to key "itemsToVersion"
end SavePersistentValues
My solution was to start brand new apps from scratch and paste in all the text.
There was one script where I would lose data, so I opened that one in the previous system and saved the peristent values to a file and then read that into the new script on the new system.
(Since then I’ve added a backup file option to my workflow)
Unfortunately it didn’t end up resolving my issue of sharing saved properties between script bundles inside an applet. Not sure if its the fact they are bundles or if their sharing properties. I posted on Macscripter as you responded there too thanks again for your input.
I don’t know if this has come up before, but I’m trying to write a Applet so that it will remember the last files dropped on it so if it’s double clicked it will run with those files.
The issue seems to be that Prefs Storage doesn’t like storing a list of aliases? Is that the case or am I missing something?
(I’d be surprised if I don’t have other scripts that store aliases with prefsstorage)
use script "PrefsStorageLib" version "1.1.0"
use AppleScript version "2.4" -- Yosemite (10.10) or later
use scripting additions
property lastDroppedFiles : {}
on open (fileList)
PersistentVariables()
set lastDroppedFiles to fileList
repeat with thisFile in fileList
-- do some stuff
end repeat
StorePersistentValues()
end open
on run
PersistentVariables()
tell me to open lastDroppedFiles
end run
on PersistentVariables()
prepare storage for (path to me) default values {lastDroppedFiles:{}}
my RetreiveStoredValues()
end PersistentVariables
on StorePersistentValues()
assign value lastDroppedFiles to key "lastDroppedFiles"
end StorePersistentValues
on RetreiveStoredValues()
set my lastDroppedFiles to value for key "lastDroppedFiles"
end RetreiveStoredValues
That’s right. If you pass it a single alias, NSUserDefaults will automatically convert and store it, but it balks at a list of them. You’ll need to convert them to paths first.