I’ve been using a module called XML Preferences by Kevin Ballard for many years, (since 2005). I still have the original .rb file). It requires another module called XML Dictionary also written by Kevin Ballard. It’s incredibly easy to use and will write an .ini file on windows or a ,pref file on Mac OS. I can’t seem to find it for download anywhere any more and his web site www.tildesoft.com is now run by Lilly Ballard who I presume is related to Kevin.
It uses GetPref and SetPref methods to save and retrieve preferences like:
SetPrefInteger("My_Integer",AnIntegerVariable)
AnIntegerVariable = GetPrefInteger("My_Integer",500) // If My_Integer doesn't exist, loads default 500
SetPrefString("My_String",SomeStringVariable)
SomeStringVariable = GetPrefString("My_String","My String Value") // If My_String doesn't exist, loads default "My String Value"
SetPrefBoolean("My_Boolean",SomeBooleanVariable)
SomeBooleanVariable = GetPrefBoolean("My_Boolean",False) // If My_Booleandoesn't exist, loads default False
You must call the following method to start using the Get and Set Methods:
InitPrefFile(kPreferencesFileName)
Call the following method to save your Preferences (Usually just before your app closes):
WritePrefFile(kPreferencesFileName)
Typically I also set the Prefs file names as a constant
I load the prefs on app open from a method App.LoadPrefs and then save prefs if they don’t exist using an App.PrefsSave method as well as saving prefs at application close
Var f As FolderItem
f = SpecialFolder.Preferences.Child(kPreferencesFileName)
If Not f.exists Then
PrefsSave
End If
Since it was freely shared when I downloaded this version I suppose there is no reason why I can’t share it with anyone that is interested. There are no restrictions in the module notes. Just PM me if you would like a copy.