This is one of "those embarrassing" problems. I know it's simple, but somehow I can't figure it out. Here's what I have
I have such an N element array of TStringLists. I don't know how many of them I'll have, since they will ultimately be lists of file paths from multiple folders, but for testing purposes I made a simpler example.
So I have such an array of TStringList. For now, let's assume that there are 3 StringLists in this array.
What I need to do is compare each element (well part of it, part after _ underscore, but for now I want to compare/display each comparison) of each StringList (even with the elements of themselves) with the elements in the other lists and find duplicates.
So what I'm thinking I'm gonna need, is that I'll have to use few (3?) nested FOR loops. But I can't figure out how to set them up. Sometimes visualization helps me in such a problem, but this time I somehow can't visualize the problem
So in my example
Compare
0_1 with 0_1, 0_2, 0_3, 0_4, 0_5, 1_5, 1_6, 1_7, 1_8, 2_5, 2_6, 2_2, 2_8, and so on..
0_2 with 0_1, 0_2, 0_3, 0_4, 0_5, 1_5, 1_6, 1_7, 1_8, 2_5, 2_6, 2_2, 2_8, and so on..
...
1_5 with 0_1, 0_2, 0_3, 0_4, 0_5, 1_5, 1_6, 1_7, 1_8, 2_5, 2_6, 2_2, 2_8, and so on..
1_6 with 0_1, 0_2, 0_3, 0_4, 0_5, 1_5, 1_6, 1_7, 1_8, 2_5, 2_6, 2_2, 2_8, and so on..
....
etc.
For now I don't care if im comparing elements few times.
procedure TForm1.Button1Click(Sender: TObject);
var
tab : array of TStringList;
i, j, k: Integer;
sstr: String;
begin
SetLength(tab,2);
tab[0] := TStringList.Create;
tab[1] := TStringList.Create;
tab[2] := TStringList.Create;
tab[0].Sorted:=true;
tab[1].Sorted:=true;
tab[2].Sorted:=true;
tab[0].add('0_1');
tab[0].add('0_2');
tab[0].add('0_3');
tab[0].add('0_4');
tab[0].add('0_5');
tab[1].add('1_5');
tab[1].add('1_6');
tab[1].add('1_7');
tab[1].add('1_8');
tab[2].add('2_5');
tab[2].add('2_6');
tab[2].add('2_2');
tab[2].add('2_8');
for i:=0 to Length(tab) do
Begin
for j:= 0 to tab[i].Count-1 do
Begin
// sstr := copy(tab[i][j],2,9);
for k:=0 to tab[i].count -1 do
Begin
Memo1.lines.add('Comparing '+ tab[i][j]+' with '+tab[i][k]);
end;
end;
end;
end;