procedure SetDelimitedText(const Value: string); overload;
Replaces the items by the fields of Value; Value takes every text kind.
| # | Name | Description |
|---|---|---|
| 1 | Value | The fields; it may be an item of this list. |
Result: stored in self (calling object)
Remarks:
Fields are separated by Delimiter; a field starting with QuoteChar runs to the closing QuoteChar, a doubled QuoteChar inside it standing for one; without StrictDelimiter the characters up to the space separate fields too and are skipped around them. A Delimiter that ends Value adds an empty field.
Examples
Fields with quotes and spaces.
uses Substr;
procedure Example;
var List: TSubstringList;
begin
List := TSubstringList.Create(8);
try
List.SetDelimitedText('a,"b c","d""e"');
Assert(List.Count = 3);
Assert(List[1] = 'b c');
Assert(List[2] = 'd"e');
Assert(List.DelimitedText = 'a,"b c","d""e"');
finally
List.Free;
end;
end;
An item of the list split into the list.
uses Substr;
procedure Example;
var List: TSubstringList;
begin
List := TSubstringList.Create(4);
try
List.Add('a b c');
List.SetDelimitedText(List[0]);
Assert((List.Count = 3) and (List[0] = 'a') and (List[2] = 'c'));
finally
List.Free;
end;
end;