Results 1 to 4 of 4

Thread: .ini-file loading algorithm

  1. #1

    .ini-file loading algorithm

    hi there!

    In my game I want to save a lot of values in .ini-files.

    I want to let the inis look like this:

    [title] //for example name of an object

    property=value
    property=value
    ..

    BTW: the unreal engine does it like this.

    Now I need to write an algorithm which loads the values and "connects" them with the right properties.
    That is maybe not so hard to do, but I don not have an idea how to make the algorithm easy and comfortable to use and that for more than one .ini-file.

    I hope you understood my problem. I'm grateful for any help,

    sven
    42 is the answer to all questions.
    <br />But what is the question to all answers?

  2. #2

    .ini-file loading algorithm

    Check out this tutorial http://www.alistairkeys.co.uk/files2.shtml by Alimonster.

  3. #3

    .ini-file loading algorithm

    If you're not afraid of the VCL you can use the Inifiles unit.

    Then all you need to do is this:
    [pascal]
    procedure Save;
    var
    Ini: TIniFile;
    a,b: Integer;
    s: String;
    // you can use other types also
    begin
    a := 12;
    b := -85;
    s := 'hello';

    Ini := TIniFile.Create('MyIni.ini');
    try
    // title property value
    Ini.WriteInteger('Something', 'A', a);
    Ini.WriteInteger('Something', 'B', b);
    Ini.WriteString ('Something', 'S', s);
    finally
    Ini.Free;
    end;
    end;

    procedure Load;
    var
    Ini: TIniFile;
    a,b: Integer;
    s: String;
    begin
    Ini := TIniFile.Create('MyIni.ini');
    try
    // title property defaultvalue
    Ini.ReadInteger('Something', 'A', 1000);
    Ini.ReadInteger('Something', 'B', 99);
    Ini.ReadString ('Something', 'S', 'test');
    finally
    Ini.Free;
    end;
    end;
    end;
    [/pascal]
    Signature:
    <br />This is a block of text that can be added to posts you make. There is a 255 character limit

  4. #4

    .ini-file loading algorithm

    Thanx a lot guys, that helps!

    sven
    42 is the answer to all questions.
    <br />But what is the question to all answers?

Bookmarks

Posting Permissions

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