[fpc-pascal] TStringList.DelimitedText seems not to work...
Bo Berglund
bo.berglund at gmail.com
Mon Nov 19 22:09:02 CET 2018
FPC 3.0.4 with Lazarus 1.8.0 on Windows 7 x64
I am trying to use TStringList containers for parsing out values of
this kind for sending to a database handler script:
2018-09-02 17:37:19<TAB>1<TAB>34.0<TAB>27.6
(<TAB> = #9)
I am using this construct, where Data holds the values in the format
shown above:
Parse := TStringList.Create;
try
Parse.Delimiter := #9;
Parse.DelimitedText := Data; //Expected to split to 4 values
p := Parse.Count;
if p < 4 then //p is actually 5 here!
exit;
readtime := Parse[0]; //This only gets the date part
source := Parse[1]; //And the time winds up here!
temp := Parse[2];
humid := Parse[3];
Result := AddReading(readtime, source, temp, humid);
So what happens here is that DelimitedText actually splits the string
on #9 AND <whitespace>!!!!
How can I stop it from parsing using space, I thought taht whan I
defined it to be <TAB> (#9) that would be what it should use....
(I think it has been mentioned here in the last year, but I cannot
find it)
--
Bo Berglund
Developer in Sweden
More information about the fpc-pascal
mailing list