Solved

Comparing Stringlist Items

Posted on 2000-03-17
2
270 Views
Last Modified: 2012-05-04
I create two stringlist to hold file names from two different drives. I want to compare all the entries in one to the entries in the other. If entries from the first do not exist in the other, then I want to copy the missing entry to a listbox. How do I do this?
0
Comment
Question by:evansj
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
2 Comments
 
LVL 13

Accepted Solution

by:
Epsylon earned 200 total points
ID: 2629754
This example uses 3 listboxes. 2 provide the input (the names from the 2 drives) and 1 for the result of the compare. Instead of the first 2 listboxes items you can pass 2 stringlist.


procedure TForm1.CompareLists(list1, list2, reslist: TStrings);
var i: Integer;
begin
  for i := 0 to list1.Count -1 do
  begin
    if list2.IndexOf(list1.Strings[i]) = -1 then
      reslist.Add(list1.Strings[i]);
  end;
end;

procedure TForm1.Button1Click(Sender: TObject);
begin
  CompareLists(ListBox1.Items, ListBox2.Items, ListBox3.Items);
end;
0
 
LVL 13

Expert Comment

by:Epsylon
ID: 2635823
Did you get it to work?
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Have you ever had your Delphi form/application just hanging while waiting for data to load? This is the article to read if you want to learn some things about adding threads for data loading in the background. First, I'll setup a general applica…
Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
How to Install VMware Tools in Red Hat Enterprise Linux 6.4 (RHEL 6.4) Step-by-Step Tutorial
Attackers love to prey on accounts that have privileges. Reducing privileged accounts and protecting privileged accounts therefore is paramount. Users, groups, and service accounts need to be protected to help protect the entire Active Directory …

732 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