I’m working on a AS Studio application that writes user defaults using the standard method.
It then runs an embedded script, after writing the user defaults.
I expected that that script could read the defaults, but not exactly:
set r to contents of (do shell script “defaults read com.wbc.castaway actionplists”)
What I expected was a list
{“*bbq”,“Podcasts”}
but the result is:
“("*bbq", Podcasts)”
Coercing to a list doesn’t help:
set r to contents of (do shell script “defaults read com.wbc.castaway actionplists”) as list
result:
{“("*bbq", Podcasts)”}
Any idea how to use the same user defaults method that AS Studo uses to read these files in a normal apple script?
Thanks
EDIT:
I’m able to do this apparently in the following way. However, this launches the application. I want to be able to read those defaults WITHOUT having to open the application – or else it defeats the purpose.
tell application “Cast Away”
tell user defaults
set actionplists to contents of default entry “actionplists” as list
end tell
end tell
The “defaults” tool and the “user defaults” feature of AS Studio are not the same. The “user defaults” feature automatically bridges textual values of a plist to the AppleScript equivalents (strings, integers, floats (reals), dates, lists (arrays), and records (dicts)) while the “defaults” tool has no idea about AppleScript classes. There maybe a way to use “user defaults” to read another plist based on the bundle ID but I don’t know how to do that. However, I’ve posted some routines for using the “defaults” tool to read a plist and coerce the values (somewhat) to AppleScript values. See http://bbs.applescript.net/viewtopic.php?id=13390.