[fpc-pascal] How to split file of whitespace separated numbers?

Bo Berglund bo.berglund at gmail.com
Sat Dec 31 17:33:56 CET 2016


On Sat, 31 Dec 2016 11:30:26 -0300, Luiz Americo Pereira Camara
<luizamericop at gmail.com> wrote:

>2016-12-31 8:18 GMT-03:00 Bo Berglund <bo.berglund at gmail.com>:
>
>> On Sat, 31 Dec 2016 11:27:53 +0100, greim
>>
>> The Readln approach followed by splitting in a stringlist is enough of
>> an improvement that I can use it.
>>
>>
>Did you look at StrUtils.ExtractSubStr ?
>
>Should be faster than TStrings;
>
>PosWord := 1;
>Word := ExtractSubstr(Line, PosWord, [' ']);
>while (Word <> '') do
>begin
>  //do work
>  Word := ExtractSubstr(Line, PosWord, [' ']);
>end;

Thanks, I did not know about this...
Unfortunately the function it is not part of the Delphi StrUtils unit
and I need my solution to be usable on Delphi since the bulk of the
program is probably too difficult to port to FPC. It contains a lot of
graphics that uses an outdated version of GLScene, which I have had to
make some minimal pathces to in order to port the program up to XE5.
But I feel a port to FPC would tax my abilities too much because of
the 3rd party stuff that has been used...

It was a good suggestion, though!
And I see that the delimiter argument can be set to StdWordDelims,
which takes care of virtually all whitespace stuff. Will use it
whenever I code in FPC and have this problem.


-- 
Bo Berglund
Developer in Sweden




More information about the fpc-pascal mailing list