Difference between revisions of "Talk:TStringList-TStrings Tutorial"

From Lazarus wiki
Jump to navigationJump to search
(IMHO, lots of questionable details. Will not help a beginner, but confuse him.)
Line 25: Line 25:
If someone agrees, I make the changes.
If someone agrees, I make the changes.
:^^The above was written by [[User:Nimral]], this comment was added by --[[User:Bart|Bart]] ([[User talk:Bart|talk]]) 22:21, 21 March 2022 (CET)

Latest revision as of 22:21, 21 March 2022

Sorry to say, but there is, IMHO, a lot of problems in the text.

"Add - This method allows you to add one string to the stringlist. It is a function that will return the Index of the String. This is where the counter comes in handy."

A counter is a counter, and an index is an index. Add returns an index, which is in no way a handy "counter". I understand what should have been emphasized (difference between index and counter), but that's not what the text says. Later on, in the samnples, the index variable is named "counter". Confusing.

// This works perfect, no double creation of stringlist... function theStringList: TStringList;

... ok, the function creates a list (what's the point of offloading this into a function?), and IMHO does NOT inhibit double creation of any kind.

"To iterate through the list it is better to use the while-do loop instead of the for-to loop"

Erm, if so, then why are there for loops used all the time in the other samples, and what exactly is better when using a while loop? IMHO, both are equally suitable, if one bases the sample on any kind of index to access the list elements. If he would use an enumeration of the individual strings and test for NIL, I'd see the point. But the sample doesn't show such a use.

Needs checking: the samples about delimited lists are working well only, if one sets the StrictDelimiter property too? Remember I had an issue there a while ago.

The samples about delimiting with a string instead of a character are more suitable as demos on how to use StringReplace, they don't have anything to do specifically with TStringList.

The line MyStringList.SkipLastLineBreak := True does not have any useful meaning (in this sample). It does IMHO belong in the File Handling samples, but isn't even mentioned there.

The text about sorting is hard to read, specifically the part about the "Duplicates" entry is unclear.

One useful option of TStringList (the usage of key/value pairs using the Names[]) array is missing, togehter with a hint that when one uses a recent version of FPC he is probably better off using generics for the same functionality.

If someone agrees, I make the changes.

^^The above was written by User:Nimral, this comment was added by --Bart (talk) 22:21, 21 March 2022 (CET)