Solved

Use Ini With ListBox1

Posted on 1998-12-01
1
246 Views
Last Modified: 2010-04-04
Hello!!!
I have a ini file and like to put all sections into listbox1
and under each section i like to add to listbox2
example of my ini
[SOFTSEEK]
URL=http://www.softseek.com
[DOWNLOAD.COM]
URL=http://www.download.com

E.g
I like to add [SOFTSEEK] into listbox1 and it's url to listbox2
URL=? into listbox2
Can i do this on event "OnCreate" of the form
Do you have a code..Thanks.....
0
Comment
Question by:mummi
1 Comment
 
LVL 3

Accepted Solution

by:
williams2 earned 50 total points
ID: 1348753
I think I've got it, try this

The INI file should look like this:
[URL0]
name=SOFTSEEK
URL=http://www.softseek.com
[URL1]
name=DOWNLOAD.COM
URL=http://www.download.com


The save it as 'urls.ini' in your project folder. Then the rest is cut'n'paste:

procedure TForm1.FormCreate(Sender: TObject);
var
  IniFile: TIniFile;
  i: Integer;
  Section,FName,FURL: String;
begin
  IniFile:= TIniFile.Create(ExtractFilePath(ParamStr(0))+'Urls.ini');
  i:= 0;
  Repeat
    Section:= 'URL'+IntToStr(i);
    FURL:= IniFile.ReadString(section,'URL','');
    FName:= IniFile.ReadString(section,'Name','');
    If FName<>'' then
    Begin
      ListBox1.Items.Add(FName);
      ListBox2.Items.Add(FURL);
    End;
    Inc(i);
  Until FName='';

end;

0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

The uses clause is one of those things that just tends to grow and grow. Most of the time this is in the main form, as it's from this form that all others are called. If you have a big application (including many forms), the uses clause in the in…
Introduction The parallel port is a very commonly known port, it was widely used to connect a printer to the PC, if you look at the back of your computer, for those who don't have newer computers, there will be a port with 25 pins and a small print…
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…

829 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question