-- Application.applescript -- -- Created by Tomasz Kukielka on Sun Jan 20 2002. -- Copyright (c) 2002 Abracode Inc. All rights reserved. -- Application.applescript property gPrefs : null -- generic object for handling preferences -- implements primitive methods and one property: prefs version -- Obj-C wrapper funcions implemented in PrefsWrapper.m -- are called for getting and setting the prefs script GenericPrefs property mVersion : 0 on GetPrefsVersion() set my mVersion to GetPrefsIntegerForKey("VERSION") return my mVersion end GetPrefsVersion on SavePrefs() if my mVersion is equal to 0 then -- on first save set version to something different from 0 set my mVersion to 1 end if SetPrefsIntegerForKey("VERSION", my mVersion) end SavePrefs on GetPrefsObjectForKey(theKey) return call method "getPrefsObjectForKey:" with parameter theKey end GetPrefsObjectForKey on GetPrefsIntegerForKey(theKey) return call method "getPrefsIntegerForKey:" with parameter theKey end GetPrefsIntegerForKey on GetPrefsBoolForKey(theKey) return call method "getPrefsBoolForKey:" with parameter theKey end GetPrefsBoolForKey on GetPrefsFloatForKey(theKey) return call method "getPrefsFloatForKey:" with parameter theKey end GetPrefsFloatForKey on GetPrefsStringForKey(theKey) return call method "getPrefsStringForKey:" with parameter theKey end GetPrefsStringForKey on SetPrefsObjectForKey(theKey, prefValue) call method "setPrefsObject:forKey:" with parameters {prefValue, theKey} end SetPrefsObjectForKey on SetPrefsIntegerForKey(theKey, prefValue) call method "setPrefsInteger:forKey:" with parameters {prefValue, theKey} end SetPrefsIntegerForKey on SetPrefsBoolForKey(theKey, prefValue) call method "setPrefsBool:forKey:" with parameters {prefValue, theKey} end SetPrefsBoolForKey on SetPrefsFloatForKey(theKey, prefValue) call method "setPrefsFloat:forKey:" with parameters {prefValue, theKey} end SetPrefsFloatForKey end script on CreateMyPrefs() script MyPrefs property parent : GenericPrefs property mCurrPrefsVersion : 1 property mRadio : 3 on ReadPrefs() GetPrefsVersion() if my mVersion is not equal to my mCurrPrefsVersion then -- set default values set my mVersion to my mCurrPrefsVersion set my mRadio to 3 else -- read prefs set my mRadio to GetPrefsIntegerForKey("FILENAME") end if end ReadPrefs on SavePrefs() if my mVersion is equal to 0 then -- on first save set version to something different from 0 set my mVersion to 1 end if --call parent method first continue SavePrefs() SetPrefsIntegerForKey("FILENAME", my mRadio) end SavePrefs end script return MyPrefs end CreateMyPrefs on clicked theObject set theName to the name of theObject if theName is "OK" then tell window "Preferences" if gPrefs is not equal to null then set mRadio of gPrefs to current row of control "Radio" tell gPrefs to SavePrefs() end if end tell close window "Preferences" quit else if theName is "Cancel" then close window "Preferences" quit end if end clicked on will open theObject set theName to the name of theObject if theName is equal to "Preferences" then if gPrefs is equal to null then set gPrefs to CreateMyPrefs() end if if gPrefs is not equal to null then tell gPrefs to ReadPrefs() tell window "Preferences" set current row of control "Radio" to (mRadio of gPrefs) end tell end if end if end will open on choose menu item theObject (*Add your script here.*) end choose menu item on update menu item theObject (*Add your script here.*) end update menu item