Saving entries as an ini.file

Need some advice on how to save multiple
entries to an ini file without the first entry being deleted.A good example
would be like the (add favourites) web
page in Internet Explorer 5.
I also need advice on how to retrieve
an item from the saved list or ini file maybe through a listbox or combobox.
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

When you add an entry to an ini file, none of these existing entries are deleted.


with TIniFile.create('my.ini')
  WriteString('Section', 'Key', 'Value);

Adds Key=Value to Section

To get an Item do this

with TIniFile.create('my.ini')
  Value := ReadString('Section', 'Key', '');

Have a read of the TIniFile help...



Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
frwAuthor Commented:
Thanks for your response ...if you use
the same button etc to automatically store a value to your inifile it will replace whats existing.My question would be in order not to replace an existing entry, how do you keep adding
data with lets say one 'ADD' button.
You would have to somehow keep changing
to a new key to have new data entered.
You can do this:

  Keys : TStringList;
  UniqueKey : String;

Keys := TStringList.Create;
with TInifile.create('my.ini') do
    ReadSection('Section', Keys);
    UniqueKey := MakeUniqueKey(Keys);
    WriteString('Section', UniqueKey, 'Value');

Of course, you will need to write the MakeUniqueKey function, but that should be fairly simple...


It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.