Writing/Reading Preference Files?!?

I have an AppleScript Studio application that I need to read/write preferences. The preferences that need to be written are just a couple paths to user specified folders. I have the preferences drawer completed and working other than actually writing the preferences to a file and reading the preferences when I open the app. Is there a simple way to do this? Anyone have sourcecode to a simple app with prefs that I can look at/copy from? Or even a link to a preferences “How To”?

I tried modifying the source code from the “Support” Xcode example project, but to no avail :frowning:

Thanks in advance!
~zach

You can pick these routines:
http://macscripter.net/exchange/comments.php?id=P188_0_1_0_C

Anyone have an actual application with those routines used? I’m still not sure where to put my info.

the two properties I want would be called “folderLocationOne” and “folderLocationTwo” …where exactly would i put those in this routine?

For example, if you’re going to store the string “foo” in the property “thing1”, and “bar” into “thing2”:

--> save the preferences:
savePrefs({{"thing1", "foo"}, {"thing2", "bar"}})
--> this is equal to:
--> Store "foo" into the key "thing1", and "bar" into the key "thing2"

--> load later the same stored preferences
set {thing1, thing2} to loadPrefs({{"thing1", "foo"}, {"thing2", "bar"}})
--> this is equal to:
--> retrieve the value of the preference "thing1". If it does not exist, assign it the default value "foo". (and the same for "thing2")

to loadPrefs(thesePrefs)
	set loadedPrefs to {}
	repeat with i in thesePrefs
		set iName to i's item 1 as text
		if default entry iName of user defaults exists then
			set end of loadedPrefs to contents of default entry iName of user defaults
		else
			set defaultValue to (i's item 2)
			set end of loadedPrefs to defaultValue
			make new default entry at end of every default entry of user defaults with properties {name:iName, contents:defaultValue}
		end if
	end repeat
	return loadedPrefs
end loadPrefs
to savePrefs(thesePrefs)
	repeat with i in thesePrefs
		set entryName to contents of (i's item 1)
		set entryValue to contents of (i's item 2)
		try
			set contents of default entry entryName of user defaults to entryValue
		on error
			make new default entry at end of every default entry of user defaults with properties {name:entryName, contents:entryValue}
		end try
	end repeat
end savePrefs

Thanks, that makes more sense to me …I’ll try and figure it out tonight!