?
Solved

Comparing Stringlist Items

Posted on 2000-03-17
2
Medium Priority
?
286 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 800 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

New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

Question has a verified solution.

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

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 Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
In this video, Percona Solution Engineer Dimitri Vanoverbeke discusses why you want to use at least three nodes in a database cluster. To discuss how Percona Consulting can help with your design and architecture needs for your database and infras…
This lesson discusses how to use a Mainform + Subforms in Microsoft Access to find and enter data for payments on orders. The sample data comes from a custom shop that builds and sells movable storage structures that are delivered to your property. …
Suggested Courses

650 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