For one memo the result is just that memo. Given the result for n memos, the result for adding another memo is just the combination of that result with the new memo.
procedure Combine(Source, Target: TStrings; const Delimiter: string = ';');
var
lst: TStringList;
S: string;
T: string;
begin
if Target.Count = 0 then begin
Target.Assign(Source);
end
else begin
lst := TStringList.Create();
try
for S in Source do
for T in Target do
lst.Add(T + Delimiter + S);
Target.Assign(lst);
finally
lst.Free;
end;
end;
end;
The calling part could look like this:
var
A: TStringList;
memo: TMemo;
begin
A := TStringList.Create;
try
for memo in [memo1, memo2, memo3] do
Combine(memo.Lines, A);
memResult.Lines := A;
finally
A.Free;
end;
end;