Remembering object settings

Being a newbie to AS Studio, I have a simple question that I couldn’t find the answer to in the forums. Is there an easy way to remember the settings of the various objects of a window (eg, which cell of each matrix is selected, whether check boxes are checked or unchecked, the contents of text fields, etc) between application runs. I can do this by giving each object a property value, then dynamically restoring those values each time the application runs and the window opens. But that becomes a bit involved if there are many objects in the window. Thank you for any helpful suggestions.

bmose

Take a look at this: Binding Your Preferences in AppleScript Studio (OS X v10.3+)

Bruce,

Thank you for this information. At first glance, using bindings to remember settings appears to be “elegant” and “powerful” (but not necessarily “easy”). I hope that the learning curve for bindings will prove to be relatively quick and painless. If you have any pearls to expedite my journey up the learning curve, I would be very grateful. Otherwise, I’ll be on my way!

bmose

Hi,

according of the “Binding Your Preferences…” article I use the following structure:

in the awake from nib, will finish launching or any initializing handler

register_Preferences()
read_Preferences()

in the will close, will quit or any quitting handler

save_Preferences()

and the handlers

on register_Preferences()
	tell user defaults
		make new default entry at end of default entries with properties {name:"myPreference", contents:1} -- or contents:"value"
		...
		register
	end tell
end register_Preferences

on read_Preferences()
	try
		tell user defaults
			set myPreference to contents of default entry "myPreference"
			...
		end tell
	on error errorText number errorNumber
		-- display or log errors
	end try
	return true
end read_Preferences
on save_Preferences()
	try
		tell user defaults
			set contents of default entry "myPreference" to myPreference
		end tell
	on error errorText number errorNumber
		-- display or log errors
	end try
end save_Preferences

Stefan,

Thank you so much for the beautiful blueprint to help me on my way.

bmose