Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6645045
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T00:14:18+00:00 2026-05-26T00:14:18+00:00

I have two stringlists that I wish to synchronize, so that equal lines get

  • 0

I have two stringlists that I wish to synchronize, so that equal lines get the same index, while different lines will be kept in the list where they originally were, and the other stringlist should get a “filler” for that index. Consider this example:

SL1:  1,1,2,3,5,8 
SL2:  1,3,5,7,9

procedure SyncStringlists(aSL1,aSL2 : TStringList; aFill : string = '-');

The procedure should change the lists to this

SL1:  1,1,2,3,5,8,-,-
SL2:  1,-,-,3,5,-,7,9

or, if the lists are sorted, to this

SL1:  1,1,2,3,5,-,8,-
SL2:  1,-,-,3,5,7,',9

How should I go about doing this?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T00:14:19+00:00Added an answer on May 26, 2026 at 12:14 am

    Try this for the case where your lists are monotone increasing.

    procedure SyncStringlists(SL1, SL2: TStringList; const Fill: string='-');
    var
      i1, i2: Integer;
    begin
      i1 := 0;
      i2 := 0;
      while (i1<SL1.Count) and (i2<SL2.Count) do begin
        if SL1[i1]<SL2[i2] then begin
          SL2.Insert(i2, Fill);
        end else if SL1[i1]>SL2[i2] then begin
          SL1.Insert(i1, Fill);
        end;
        inc(i1);
        inc(i2);
      end;
      while SL1.Count<SL2.Count do begin
        SL1.Add(Fill);
      end;
      while SL2.Count<SL1.Count do begin
        SL2.Add(Fill);
      end;
    end;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have two DataGridViews that have the same column schema (although two different DataViews
I have two BizTalk 2010 servers that belong to the same BizTalk group. They
I have two lists of the same type. That type does not have an
I have a list wrapper that maintains two Tstringlists and a TClassList I need
I have two applications written in Java that communicate with each other using XML
I have two different Silverlight UserControls imported with MEF from two different xaps. The
I have two header files named string.h in different libraries, they are conflicted with
I have two classes: public class TestClass1 { public int TestInt { get; set;
I have two arraylists, one contains Strings and the other contains Classes that have
I have two inputs with the same date, but i want to separate the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.