As I told earlier, I found a bug in TStringlist. But this is general in pascal, not only Lazarus / FPC.
I have this piece of code:This is my textfile:
program project1; uses classes, sysutils; var slTest : TStringlist; slRegel : TStringlist; index : integer; begin slTest := TStringlist.create; slRegel := TStringlist.create; try slTest.LoadFromFile('test.txt'); slRegel.Delimiter := ';'; slRegel.QuoteChar := '"'; slRegel.StrictDelimiter := true; for index := 0 to slTest.count - 1 do begin slRegel.DelimitedText := slTest[index]); writeln(inttostr(slRegel.Count)) end; readln(); finally slregel.free; sltest.free; end; end. When I run this sample, the following results in:
field11;field12 ;field13;field14 field21;field22 ;field23;field24 field31;"field32" ;field33;field34 field41;field42 ;field43;field44
4
4
5
4
The reason is the double quotes together with a few spaces afterwards. TStringlist creates an extra entry.
Am I right or not?
The workaround is:
slRegel.DelimitedText := StringReplace(slTest[index],'"','',[rfReplaceAll]);
But using strictdelimiter should it work with this workaround.
Changed your first code to a procedure and loaded the const text
The result is 4 / 4 / 4 / 4
Changed your first code to rrunning program. Without compiler errors.
Threw out the stream and the try.
Result is 4 / 4 / 4 / 4
fpc 3.04, lin 64
I submitted a bug report with a simple test program (https://bugs.freepascal.org/view.php?id=37978).As I thought this problem has a really minor chance to fix. It's a general problem. Thanks for trying, WP.