Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!


Click here to return to the 'Code samples for an AppleScript preferences system' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
Code samples for an AppleScript preferences system
Authored by: designr on Apr 06, '05 02:22:33PM

Maybe this is a silly question but, why can't you use the "Property" declaration to establish nonvolatile preferences?

Applescript stores and retains "Property" values between launches.

--First, declare properties (which like "Globals" can be called from within subroutines):

property my_file_list : {}
property my_pref_1_option_list : {¬
"list_item_1", ¬
"list_item_2", ¬
"list_item_3", ¬
"list_item_4"}
property my_pref_1 : {}
property my_pref_2 : ""
property my_pref_3 : ""
property my_pref_4 : ""

--Then, create a steps to check if each pref is empty:

if my_file_list = {} then set_my_file_list()
if myPref_1 = {} then set_my_pref_1()
if myPref_2 = "" then set_my_pref_2()
if myPref_3 = "" then set_my_pref_3()
if myPref_4 = "" then set_my_pref_4()

--Then create a subroutine to set each pref (you can use other triggers to call these subroutines if you want to change the values):

on set_my_file_list ()
set my_file_list to choose file with multiple selections allowed
end set_my_file_list

on set_my_pref_1 ()
set my_pref_1 to choose from list my_pref_1_option_list with prompt "Choose:" with multiple selections allowed
end set_my_pref_1

on set_my_pref_2 ()
set my_pref_2 to display dialog "Type Whatever:" default answer "" buttons {"Skip","OK"} default button 2
end set_my_pref_2

--And so on....



[ Reply to This | # ]
Code samples for an AppleScript preferences system
Authored by: aamann on Apr 06, '05 02:30:37PM

This won't work since properties are not preserved between runs for AppleScript Studio applications.



[ Reply to This | # ]