Herzlich willkommen in der Delphi-PRAXiS, Alex.
Hier ein Nachrüst-Kit für dich:
Delphi-Quellcode:
function DelimitedText(s: TStrings; const cDelimiter: Char = ',';
const cQuote: Char = '"'): String;
var
i, iPos, iLength: Integer;
line: String;
begin
if s.Count = 0 then Result := '' else
// calculate resulting length
begin
// account for delimiters
iLength := Pred(s.Count);
for i := 0 to Pred(s.Count) do
begin
line := s[i];
// account for outer quotes
Inc(iLength, Length(line) + 2);
for iPos := 1 to Length(line) do
// account for escape chars
Inc(iLength, Ord(line[iPos] = cQuote));
end;
// dimension result
SetLength(Result, iLength);
iPos := 1;
for i := 0 to Pred(s.Count) do
begin
if i > 0 then
begin
Result[iPos] := cDelimiter;
Inc(iPos);
end;
line := AnsiQuotedStr(s[i], cQuote);
Move(line[1], Result[iPos], Length(line));
Inc(iPos, Length(line));
end;
end;
end;
Freundliche Grüße vom marabu