Questions tagged [tstringlist]

TStringList is a RTL class whose purpose is to store and manipulate a list of strings. It is defined in Classes.pas

163 questions
57
votes
5 answers

Delphi: StringList Delimiter is always a space character even if Delimiter is set

I am having trouble with the delimiter in the TStringList Class. Take a look: var s: string; sl: TStringList; begin sl := TStringList.Create; s := 'Users^foo bar^bar foo^foobar^barfoo'; sl.Delimiter := '^'; sl.DelimitedText := s; …
Acron
  • 1,308
  • 3
  • 19
  • 32
42
votes
4 answers

Why variables are declared as TStrings and created as TStringList?

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(…
Fabio Vitale
  • 2,167
  • 3
  • 24
  • 34
31
votes
4 answers

TStringList splitting bugs

Recently I've been informed by a reputable SO user, that TStringList has splitting bugs which would cause it to fail parsing CSV data. I haven't been informed about the nature of these bugs, and a search on the internet including Quality Central did…
Sertac Akyuz
  • 52,752
  • 4
  • 91
  • 157
31
votes
8 answers

TStringList vs. TList

what is the difference in using a standard type sl: TStringList compared to using a generic TList type sl: TList ? As far as I can see, both behave exactly the same. Is it just another way of doing the same thing? Are there…
Holgerwa
  • 3,398
  • 7
  • 40
  • 49
20
votes
1 answer

Why does memo.Lines use TStrings instead of TStringList?

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?
Illiou
  • 205
  • 1
  • 2
  • 8
17
votes
2 answers

delphi array of string stringlist conversion

Is there a simple way in delphi to convert an array of strings to a tstringlist?
xianghua
  • 173
  • 1
  • 1
  • 4
15
votes
2 answers

Removing duplicate from TStringList

I am parsing a dataset and assigning values to TStringList i want to avoid the duplicates. I use the following code but still duplicates are inserted. channelList := TStringList.Create; channelList.Duplicates := dupIgnore; try …
Jeeva
  • 4,329
  • 2
  • 28
  • 55
15
votes
3 answers

Converting TStringlist to string with delimiter

I have a list of strings stored in TStringList, i want to convert it into string seperated by commas and i use the following code channelList: TStringList; aCurrentChannel := …
Jeeva
  • 4,329
  • 2
  • 28
  • 55
14
votes
3 answers

How can I get TStringList to sort differently in Delphi

I have a simple TStringList. I do a TStringList.Sort on it. Then I notice that the underscore "_" sorts before the capital letter "A". This was in contrast to a third party package that was sorting the same text and sorted _ after A. According to…
lkessler
  • 19,414
  • 31
  • 125
  • 196
12
votes
1 answer

Using TStringList's AddObject with integers?

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?
IElite
  • 1,768
  • 7
  • 36
  • 63
11
votes
3 answers

Compare to Stringlist

I must compare 2 stringlist , I wonder if the search the first stringlist inside the second stringlist is the only or the recommended version to execute this problem My code would go like this var aFirstStrList: TStringList ; …
Franz
  • 1,656
  • 24
  • 46
10
votes
7 answers

TStringList, Dynamic Array or Linked List in Delphi?

I have a choice. I have a number of already ordered strings that I need to store and access. It looks like I can choose between using: A TStringList A Dynamic Array of strings, and A Linked List of strings (singly linked) and Alan in his comment…
lkessler
  • 19,414
  • 31
  • 125
  • 196
9
votes
5 answers

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

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.
Kumar S
  • 393
  • 2
  • 5
  • 15
9
votes
2 answers

How do I prevent TStrings.SaveToFile creating a final empty line?

I have a file .\input.txt like this: aaa bbb ccc If I read it using TStrings.LoadFromFile and write it back (even without applying any changes) using TStrings.SaveToFile, it creates an empty line at the end of the output file. var Lines :…
Fabrizio
  • 6,598
  • 5
  • 31
  • 75
8
votes
4 answers

Better way to resize a TStringList?

I frequently find that I need to 'resize' a a TStringList to hold exactly N elements, either adding additional empty strings to the list, or deleting unneccessary ones. On a C++ STL container I could use the resize method, but as that doesn't seem…
Roddy
  • 63,052
  • 38
  • 156
  • 264
1
2 3
10 11