Cleaned up the code and shared at GitHub, please see the first post for links and info.
Petr
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 usageuses "iniFile"
To make work with multiple files easier, and to avoid specifying the file name over and over again, module provides simple object:
Let me know if you need anything to be added.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
Petr
Last edited by Petr Schreiber; 12-03-2016 at 21:36.
Learn 3D graphics with ThinBASIC, learn TBGL!
Windows 10 64bit - Intel Core i5-3350P @ 3.1GHz - 16 GB RAM - NVIDIA GeForce GTX 1050 Ti 4GB
Cleaned up the code and shared at GitHub, please see the first post for links and info.
Petr
Learn 3D graphics with ThinBASIC, learn TBGL!
Windows 10 64bit - Intel Core i5-3350P @ 3.1GHz - 16 GB RAM - NVIDIA GeForce GTX 1050 Ti 4GB
Petr,
The wiki link in your "How to use" link is on thinBasic_enVar.dll, not thinBasic_iniFile.dll.
Bill
Last edited by Billbo; 13-03-2016 at 14:21.
Fixed, thank you very much!
Petr
Learn 3D graphics with ThinBASIC, learn TBGL!
Windows 10 64bit - Intel Core i5-3350P @ 3.1GHz - 16 GB RAM - NVIDIA GeForce GTX 1050 Ti 4GB
Petr,
Thanks, as always. It is okay, now.
Bill
Petr,
I'm fascinated by your implementation of the INI class: it is so elegant.
Do you mind if I get it and add into official INI module?
I think I will release INI module in GitHub
Thanks a lot
Eros
PS: next thinBasic version will have something like DIM ... AS ... NEW ... I'm finishing to test it:
Current syntax will continue to be valid to be used when it is not possible to start constructor during variable declaration, that is:Dim config As New IniFile(APP_SourcePath + "settings.ini")
Dim config As IniFile '... config = New IniFile(APP_SourcePath + "settings.ini")
www.thinbasic.com | www.thinbasic.com/community/ | help.thinbasic.com
Windows 10 Pro for Workstations 64bit - 32 GB - Intel(R) Xeon(R) W-10855M CPU @ 2.80GHz - NVIDIA Quadro RTX 3000
Hi Eros,
please do merge as you wish
That new syntax looks tasty and saves some typing, yummy!
Petr
Learn 3D graphics with ThinBASIC, learn TBGL!
Windows 10 64bit - Intel Core i5-3350P @ 3.1GHz - 16 GB RAM - NVIDIA GeForce GTX 1050 Ti 4GB
Bookmarks