I answer my question for the second time in a row) the answer comes as soon as I ask.
Here is such an algorithm - I collect text from all files into one TStringList, sort, delete duplicates;
Next, I start a cycle through the lines of this string player, and look for this line in each file (after loading it into a string player, sorting it, removing duplicates). If more than one match is found (in more than one file), after checking for the presence of this string in the files, I output the string and the list of files in the resulting memo.
And here is the code itself:
procedure TForm2.Button1Click(Sender: TObject); var all,f1,f2,result:TStringList; i,j,l,m,n:integer; resstr:string; rescount:integer; begin rescount:=0; all:=TStringList.Create; f1:=TStringList.Create; f2:=TStringList.Create; result:=TStringList.Create; all.Sorted:=true; all.Duplicates:=dupIgnore; f1.Sorted:=True; f1.Duplicates:=dupIgnore; for n := 0 to memo1.Lines.Count-1 do begin f1.LoadFromFile(memo1.Lines[n]); all.AddStrings(f1); end; for j := 0 to all.Count-1 do begin for I := 0 to memo1.Lines.Count-1 do begin f1.LoadFromFile(memo1.Lines[i]); if (f1.IndexOf(all.Strings[j])>-1) then begin resstr:=resstr+' '+extractfilename(memo1.Lines[i]); inc(rescount); end; end; if rescount>1 then result.Add(all.Strings[j]+' '+resstr); resstr:=''; rescount:=0; end; memo2.Lines.AddStrings(result); end;
</ code>