Results 1 to 7 of 7

Thread: IniFile - module for INI file handling

Threaded View

Previous Post Previous Post   Next Post Next Post
  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

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
  •