Solved

Comparing Stringlist Items

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Delphi with SQL Natvie Client 15 86
Path  to current project in Delphi. 2 72
Delphi cmd execution 6 56
How to load 2 images in same column in Delphi 2 34
This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
This tutorial gives a high-level tour of the interface of Marketo (a marketing automation tool to help businesses track and engage prospective customers and drive them to purchase). You will see the main areas including Marketing Activities, Design …
Windows 10 is mostly good. However the one thing that annoys me is how many clicks you have to do to dial a VPN connection. You have to go to settings from the start menu, (2 clicks), Network and Internet (1 click), Click VPN (another click) then fi…

867 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

17 Experts available now in Live!

Get 1:1 Help Now