TMemIniFile

Ask questions about how to create a script or swap scripts with other users.
Post Reply
User avatar
rjbill
Posts: 898
Joined: 13 Jun 2011 06:36

TMemIniFile

Post 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.
RJTE version 16.21 (Actual) - 64-bit
Win 10 Pro 64-bit 8 GB RAM Intel Core i7-6700 3.40 GHz SCSI Hard Drive 1 TB

Note: The signature is dynamic, not static,
so it may not show the correct version above
that was in use at the time of the post.
User avatar
Rickard Johansson
Site Admin
Posts: 6739
Joined: 19 Jul 2006 14:29

Re: TMemIniFile

Post 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
User avatar
rjbill
Posts: 898
Joined: 13 Jun 2011 06:36

Re: TMemIniFile

Post by rjbill »

Okay. Thanks.

So it's been broken and no one noticed because no one tried it?
RJTE version 16.21 (Actual) - 64-bit
Win 10 Pro 64-bit 8 GB RAM Intel Core i7-6700 3.40 GHz SCSI Hard Drive 1 TB

Note: The signature is dynamic, not static,
so it may not show the correct version above
that was in use at the time of the post.
User avatar
rjbill
Posts: 898
Joined: 13 Jun 2011 06:36

Re: TMemIniFile

Post 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.
RJTE version 16.21 (Actual) - 64-bit
Win 10 Pro 64-bit 8 GB RAM Intel Core i7-6700 3.40 GHz SCSI Hard Drive 1 TB

Note: The signature is dynamic, not static,
so it may not show the correct version above
that was in use at the time of the post.
Post Reply