The INIFile module is easy to use implementation of INI file handling for thinBasic.
It is provided with full source code, unit tests and binaries here:
https://github.com/petrSchreiber/thinBasic_iniFile
How to use:
Get the DLL from https://github.com/petrSchreiber/thi...eleases/latest
Place the thinBasic_iniFile.dll to Mod directory inside your thinBasic installation. Since then, you should be able to reference the module easily as:
Examples of usage
To make work with multiple files easier, and to avoid specifying the file name over and over again, module provides simple object:
Uses "IniFile", "Console"
' -- Hook it to any file you need
Dim config As IniFile
config = New IniFile(APP_SourcePath + "settings.ini")
' -- Write data this way - first is section, then key
config.SetKey("Screen", "Width", "1920")
config.SetKey("Screen", "Height", "1080")
config.SetKey("User", "Name", "DarthVader")
config.SetKey("User", "Password", "Force")
' -- Read the data back, even with default values
PrintL config.GetKey("Screen", "Width") + "x" + config.GetKey("Screen", "Height") + "@" + config.GetKey("Screen", "BitDepth", "32")
PrintL
' -- List sections
PrintL "Sections:", config.GetSections(",")
PrintL
' -- List keys
PrintL "Keys for Screen:", config.GetKeys("Screen", ",")
PrintL
PrintL "Keys for User:", config.GetKeys("User", ",")
PrintL
WaitKey
Let me know if you need anything to be added.
Petr
Bookmarks