Версия для печати темы
Нажмите сюда для просмотра этой темы в оригинальном формате
Форум программистов > Delphi: Общие вопросы > CommaText не работает


Автор: MadCoder 5.11.2008, 15:40
Здравствуйте!

Не пойму, в чем дело - не работает CommaText.

Мне нужно получить список вида: "1","2","3","4","5" и т.д. из TStringList.

Пишу следующее:
Код

var
A: TStringlist;
begin
A:=TStringlist.Create;
A.Add('1');
A.Add('2');
A.Add('3');
..
ShowMessage(A.CommaText);

Почему-то отображается без кавычек: 1,2,3.
 smile 

Автор: CodeMonkey 5.11.2008, 16:20
Так и должно быть.
CommaText + F1:
Цитата
When retrieving CommaText, any string in the list that include spaces, commas or quotes will be contained in double quotes, and any double quotes in a string will be repeated. When assigning CommaText, the value is parsed as SDF formatted text. For SDF format, strings are separated by commas or spaces, and optionally enclosed in double quotes. Double quote marks that are part of the string are repeated to distinguish them from the quotes that surround the string. Spaces and commas that are not contained within double quote marks are delimiters. Two commas next to each other will indicate an empty string, but spaces that appear next to another delimiter are ignored.

Возможно, вам нужен DelimitedText?

Автор: aktuba 5.11.2008, 16:47
Кавычки будут только тогда, когда есть пробелы в строке.

Автор: MadCoder 5.11.2008, 18:09
Спасибо!

Powered by Invision Power Board (http://www.invisionboard.com)
© Invision Power Services (http://www.invisionpower.com)