RE:Storing preferences, part deux
RE:Storing preferences, part deux
- Subject: RE:Storing preferences, part deux
- From: James Burns <email@hidden>
- Date: Fri, 7 Feb 2003 08:05:35 -0500
After implementing preferences in my app, I learned a few more things,
so let me reiterate them here in case someone else goes looking for
answers to these questions. The reference for this is in the
AppleScript Studio terminology Reference under Applications
Suite:Classes:default entry. I'm stealing my examples from that.
What "default entry" lets you do is set user preferences. I'm
specifically using this in an AppleScript Studio project.
You make new entries thusly:
make new default entry at end of default entries of user defaults with
properties {name:"defaultName", contents:"Testing"}
This writes new entries in the ~/library/Preferences/YourApp.plist
file. (This code makes the entries start AFTER the default entries
(which would be bad to mess with).
To change them, just reference them the way you would other containers:
set contents of default entry "defaultName" of user defaults to "Check"
To retrieve them, using the example from the previous one, just use:
set myName to contents of default entry "defaultName" of user defaults
I found that it's go to trap for a lack of preferences on the first run
with a try statement somewhere while starting up, by trying to retrieve
values, and on error, initializing values. I write the preferences in
an "on quit handler."
It seems to work like a charm.
-----
James Burns
http://www.jamesburnsdesign.com
_______________________________________________
applescript-users mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/applescript-users
Do not post admin requests to the list. They will be ignored.