Results 1 to 7 of 7

Thread: IniFile - module for INI file handling

  1. #1
    Super Moderator Petr Schreiber's Avatar
    Join Date
    Aug 2005
    Location
    Brno - Czech Republic
    Posts
    7,153
    Rep Power
    736

    IniFile - module for INI file handling

    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:

    uses "iniFile"
    
    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
    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

  2. #2
    Super Moderator Petr Schreiber's Avatar
    Join Date
    Aug 2005
    Location
    Brno - Czech Republic
    Posts
    7,153
    Rep Power
    736
    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

  3. #3
    Member
    Join Date
    Nov 2012
    Location
    Missouri, USA
    Posts
    113
    Rep Power
    30
    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.

  4. #4
    Super Moderator Petr Schreiber's Avatar
    Join Date
    Aug 2005
    Location
    Brno - Czech Republic
    Posts
    7,153
    Rep Power
    736
    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

  5. #5
    Member
    Join Date
    Nov 2012
    Location
    Missouri, USA
    Posts
    113
    Rep Power
    30
    Petr,

    Thanks, as always. It is okay, now.

    Bill

  6. #6
    thinBasic author ErosOlmi's Avatar
    Join Date
    Sep 2004
    Location
    Milan - Italy
    Age
    57
    Posts
    8,817
    Rep Power
    10
    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:
    Dim config As New IniFile(APP_SourcePath + "settings.ini")
    
    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 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

  7. #7
    Super Moderator Petr Schreiber's Avatar
    Join Date
    Aug 2005
    Location
    Brno - Czech Republic
    Posts
    7,153
    Rep Power
    736
    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

Similar Threads

  1. Next thinBasic: ZIP file handling
    By ErosOlmi in forum thinBasic vaporware
    Replies: 2
    Last Post: 29-01-2012, 19:56
  2. File handling in TBGL module
    By ErosOlmi in forum TBGL General
    Replies: 3
    Last Post: 22-02-2007, 00:18
  3. Module data handling
    By ErosOlmi in forum Statistics Module
    Replies: 0
    Last Post: 07-09-2006, 10:52

Members who have read this thread: 0

There are no members to list at the moment.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •