Page 1 of 1

TMemIniFile

Posted: 23 Jan 2024 22:25
by rjbill
Now I can't get this .ini stuff to work.

I originally tried writing an Integer, but it wouldn't accept the variable as an integer, no matter what I did. (WriteInteger)

So I decided to write it as a string.

nTabColumn is created using:

var nTabColumn = StrToInt (InputBox ("Tab To Column", "Tab To Column?", "0"));

Code: Select all

      TMemIniFile tiIni = TMemIniFile.Create ("TabToColumn_Settings.ini");

      //var nTabColumn = tiIni.ReadInteger ("Settings", "TabToColumn", nTabColumn);
      tiIni.WriteString ("Settings", "TabToColumn", IntToStr (nTabColumn));
                                                  
      tiIni.UpdateFile;
      tiIni.Free;
The .ini file looks like this:

Code: Select all

[Settings]
TabToColumn=TabToColumn
I've tried multiple attempts at various ways to write it and convert it.

And I couldn't find any examples.

Re: TMemIniFile

Posted: 23 Jan 2024 23:00
by Rickard Johansson
It's fixed in the next release (v16.11).

I tested with the code below (using v16.11) and it works fine.

Code: Select all

// JScript

TMemIniFile tiIni = TMemIniFile.Create ("TabToColumn_Settings.ini");

var nTabColumn = 10;
tiIni.WriteInteger("Settings", "TabToColumn", nTabColumn);
                                            
tiIni.UpdateFile;
tiIni.Free;
[Settings]
TabToColumn=10

Re: TMemIniFile

Posted: 23 Jan 2024 23:45
by rjbill
Okay. Thanks.

So it's been broken and no one noticed because no one tried it?

Re: TMemIniFile

Posted: 23 Jan 2024 23:55
by rjbill
BTW -- I'm using this .ini for another Script called "TabToLastColumn",
which will use this stored value.

Unfortunately, it will have to open and read the file every time it's called, which is not ideal.

It's the only way I could see to save a STATIC value between executions.

It would be nice if there was a more internal way to do it that would be easier and faster.

Like maybe a Static Object that would hold some number of values (10?) that could be stored and retrieved per Edit Session.