Solved

Comparing Stringlist Items

Posted on 2000-03-17
2
251 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
  • 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

Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

Join & Write a Comment

Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…
This video discusses moving either the default database or any database to a new volume.

747 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

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now