tstringlist

Why does memo.Lines use TStrings instead of TStringList?

ぐ巨炮叔叔 提交于 2019-12-08 14:34:13
问题 Why does Memo.Lines use the abstract class TStrings ? Why doesn't it use TStringList instead? And should I convert it to TStringList before working with it? 回答1: TMemo.Lines , TListBox.Items , TComboBox.Items , etc. ; all are declared as TStrings . Beware, talking about the property that is! The internal created types are TMemoStrings , TListBoxStrings and TComboBoxStrings respectively, which are all descendants of TStrings and differ all in way of storage. And why? For interchangeability and

How do I store and load a list of key-value pairs in a string?

血红的双手。 提交于 2019-12-07 11:10:07
问题 I have a list of strings and the values they are to be replaced with. I'm trying to combine them in a list like 'O'='0',' .'='.', ... so it's easy for me to edit it and add more pairs of replacements to make. Right now the best way I could think of it is: var ListaLimpeza : TStringList; begin ListaLimpeza := TStringList.Create; ListaLimpeza.Delimiter := '|'; ListaLimpeza.QuoteChar := '"'; ListaLimpeza.DelimitedText := 'O=0 | " .=."'; ShowMessage('1o Valor = '+ListaLimpeza.Names[1]+' e 2o

Parsing a string using a delimiter to a TStringList, seems to also parse on spaces (Delphi)

◇◆丶佛笑我妖孽 提交于 2019-12-07 03:35:40
问题 I have a simple string which is delimited by some character, let's say a comma. I should be able to create a TStringList and set it's delimiter to a comma then set the DelimitedText to the text I want to parse and it should be automaticlly parsed. The problem is when I look at the output it also includes spaces as delimiters and chops up my results. How can I avoid this, or is there a better way to do this. 回答1: There's a StrictDelimiter property on the TStringList. Set it to True and it will

How can I show the contents of a TStringList in the debugger?

烈酒焚心 提交于 2019-12-07 00:26:57
问题 I want to display the entire content of a TStringList while debugging the application. Instead I just get pointers. The Flist is showing only the address. 回答1: I use the visualizers now that I have D2010. I used to use a function I called CArray that would return an array of strings. If I added CArray(MyStringList) to the watch window, I would be able to examine the contents of the string list. I used to be employed to write VB6 code and I sort of liked the various 'C' functions for

How do I store and load a list of key-value pairs in a string?

和自甴很熟 提交于 2019-12-05 17:39:17
I have a list of strings and the values they are to be replaced with. I'm trying to combine them in a list like 'O'='0',' .'='.', ... so it's easy for me to edit it and add more pairs of replacements to make. Right now the best way I could think of it is: var ListaLimpeza : TStringList; begin ListaLimpeza := TStringList.Create; ListaLimpeza.Delimiter := '|'; ListaLimpeza.QuoteChar := '"'; ListaLimpeza.DelimitedText := 'O=0 | " .=."'; ShowMessage('1o Valor = '+ListaLimpeza.Names[1]+' e 2o Valor = '+ListaLimpeza.ValueFromIndex[1]); This works, but it's not good for visuals, since I can't code

Parsing a string using a delimiter to a TStringList, seems to also parse on spaces (Delphi)

▼魔方 西西 提交于 2019-12-05 07:06:53
I have a simple string which is delimited by some character, let's say a comma. I should be able to create a TStringList and set it's delimiter to a comma then set the DelimitedText to the text I want to parse and it should be automaticlly parsed. The problem is when I look at the output it also includes spaces as delimiters and chops up my results. How can I avoid this, or is there a better way to do this. There's a StrictDelimiter property on the TStringList. Set it to True and it will only parse on the delimiter, not the spaces. That's standard, documented behavior of the TStrings

Stringlist with delimiter as a string?

假如想象 提交于 2019-12-04 17:49:40
I have an attribute called HistoryText in a object that is stored as a string. I want to show all rows in a grid. I should be able to delete and edit rows in the grid. The format is: 16.5.2003-$-12:09-$-anna-$-Organization created 2.6.2005-$-13:03-$-jimmy-$-Organization edited 19.12.2005-$-13:33-$-madeleine-$-Organization edited So each row have 4 fields, date, time, user, and message with a delimiter string as '-$-'. As the delimiter a string and not a char it cannot be assigned to the stringlists delimiter property. I have a routine to extract the string to a Stringlist: procedure

Using TStringList's AddObject with integers?

一笑奈何 提交于 2019-12-04 17:33:12
问题 Using delphi 7: How can I add an integer to the object portion of a stringlist item, using AddObject ? How can I retrieve the integer back from a object property of stringlist item? How do I free all objects and list when done? 回答1: Q: How can i add an integer to the object portion of a stringlist item, using AddObject? A: Just cast the integer value to TObject List.AddObject('A string',TObject(1)); Q: How can a retrieve the integer back from a object property of stringlist item? A: Cast to

Why variables are declared as TStrings and created as TStringList?

不问归期 提交于 2019-12-04 15:00:27
问题 Why variables are declared as TStrings and created as TStringList ? eg: the var sl is declared as TStrings but created as TStringList var sl : TStrings; begin sl := TStringList.Create; // add string values... sl.Add( 'Delphi' ); sl.Add( '2.01' ); // get string value using its index // sl.Strings( 0 ) will return // 'Delphi' MessageDlg( sl.Strings[ 0 ], mtInformation, [mbOk], 0 ); sl.Free; end; 回答1: To my mind that is rather pointless albeit completely harmless. You could perfectly well

TStringList vs. TList<string>

£可爱£侵袭症+ 提交于 2019-12-03 11:35:35
问题 what is the difference in using a standard type sl: TStringList compared to using a generic TList type sl: TList<string> ? As far as I can see, both behave exactly the same. Is it just another way of doing the same thing? Are there situations where one would be better than the other? Thanks! 回答1: TStringList is a descendant of TStrings. TStringList knows how to sort itself alphabetically. TStringList has an Objects property. TStringList doesn't make your code incompatible with all previous