Results 1 to 5 of 5

Thread: WriteINI(), ReadINI() tutorial

  1. #1
    Join Date
    Mar 2009
    Location
    Ireland
    Posts
    111
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default WriteINI(), ReadINI() tutorial

    This is my first tutorial, on a handy little procedure.

    WriteINI() is a very nice, and easy way to save peoples settings from a DeclarePlayers Procedure.

    The format is:
    Code:
    WriteINI(Section, Key, Value, FilePath);
    
    Value := ReadINI(Section, Key, FilePath);


    A section can be used for different players.
    the key would be like 'user', and the value would be the username.

    this is best inplimented in forms, for a save and load button.

    A working example:
    Code:
      program SaveAndLoad;
    
      const
        Info = 'Information_goes_here';
      
      var
        filename:string;
        Value:string;
    
      procedure Save;
      begin
        WriteINI('TestSection', 'TestKey', Info, FileName);
      end;
    
      procedure Load;
      begin
        Value := ReadINI('TestSection', 'TestKey', Filename);
      end;
     
      begin
        FileName := AppPath + 'Scripts\settings.ini';
        Save;
        Load;
        WriteLn(Value);
      end.
    So this saves the Info into 'Scripts/settings.ini' in the format of
    Code:
    [TestSection]
    TestKey=Information_goes_here
    and loads it to write it out.

    this could be put behind a "Save" button on a form to save it all, so next time you would only have to load it, by pressing "Load"...

    Code:
      DeleteINI(Section, Key, FilePath);
    This deletes the Key passed to it and the Value associated with it.



    Anyways, this is my first tutorial...

    Please leave me any comments
    Last edited by mc_teo; 07-30-2009 at 05:15 PM.

  2. #2
    Join Date
    Jul 2007
    Location
    Norway.
    Posts
    1,938
    Mentioned
    3 Post(s)
    Quoted
    0 Post(s)

    Default

    Thanks for making this tutorial, I'll probably redirect people who want to find out more about INIs to this tutorial in a project I'm working on as we speak. It would be really great if you could add more info into it.
    Take a look at Wikipedia, for instance - there's a great article about INI files there.

    Oh, and from looking at your signature, it seems as you want rep.
    Enjoy 3 new reputation points from me.

  3. #3
    Join Date
    Jan 2008
    Location
    California, US
    Posts
    2,765
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Enjoy 4 new reputation points from me even though I already have my own .

  4. #4
    Join Date
    Apr 2007
    Location
    The Netherlands
    Posts
    5,553
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    I use Ini files all the time, but I am going to switch to register since I am able to acces that and scar isn't, but scar is very good for ini files!
    Do you have a question, you can also ask me.
    Note: Ini files aren't that complicated
    ~Hermen

  5. #5
    Join Date
    Aug 2007
    Location
    in a random little world
    Posts
    5,778
    Mentioned
    0 Post(s)
    Quoted
    7 Post(s)

    Default

    change them to scar tags
    and change
    SCAR Code:
    WriteINI(Section, Key, Value, FilePath);

    Value := Read(Section, Key, FilePath);
    to
    SCAR Code:
    WriteINI(Section, Key, Value, FilePath);

    Value := ReadINI(Section, Key, FilePath);
    very good

    now add a bit of info about DeleteINI and how its used and what it does etc.

    ~shut

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

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