PrefsStorageLib Questions

I having an issue copying the script I wrote in MacOS 11.6 to 10.11.6

The script works just fine in Script Debugger, but when I save it as an applet, both Enhanced and Apple, I get this error message in the Apple Applet:

The 'prepare storage' command was unable to initialize user defaults. Unknown error (-2700)

With buttons Edit and OK, which work.

In the Enhanced Applet I get this error message

Runtime Script Error
The 'Prepare storage' command was unable to initialize user defaults. Unknown error.

The only button is “Quit” but as soon as I hit quit a new dialog appears, and that repeats until I force quit.

The 'assign value' command failed, with the error: The 'prepare storage' command has not yet been called by this script

The only button is quit, and hitting quit goes into an endless repeat where that second dialog keeps popping up, until I force quit.

Below are the handlers that I use to initialize get and store persistent variables.

→ Script Debugger: 7.0.13 (7A125)
→ PrefsStorageLib: 1.1.0 (8)
→ Mac OS: 10.11.6 (15G22010)

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

Can you email me sample applets?

@estockly were you able to resolve this? Im having same issue.

No, and @ShaneStanley and I tried.

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)

Thanks Shane helped resolve it. It was a matter of using:

prepare storage for domain "my domain name here" for Scripts/Script Bundles

prepare storage for (path to me) for Applets

1 Like

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.