Re: Faster way of making long string?



Thanks for letting me know about using CommaText with TStringList.
It's an easy way to do it.

But looking at the code in the Classes unit I found though that it uses the
same string joining technique as I used in my own loop so is unlikely to be
any faster.

Ian.

"Ekkehard Domning" <edo@xxxxxxxx> wrote in message
news:d4fuke$7me$02$1@xxxxxxxxxxxxxxxxxxxx
> Hello Ian,
>
> Ian Hinson wrote:
> > I want to make a string of numbers from an integer list.
>
> how do You like this?
>
> var
> i: integer;
> lstNumbers: TIntegerList;
> strOut: string;
> sl : TStringList;
> begin
> strOut := '';
> sl := TStringList.Create;
> try
> for i := 0 to lstNumbers.Count-1 do
> sl.Add(IntToStr(lstNumbers[i]);
> strOut := sl.CommaText;
> finally
> sl.Free;
> end;
> end;
>
> All NumberStrings are placed in List, strOut is composed from the list
> strings, list is freed after usage. Should be faster.
> SetLength would be nice, but than You have to call IntToStr twice for each
> entry, first to get the length, second to get the string.
>
>> Thanks,
>> Ian.
>
> Best regards
> Ekkehard Domning


.


Quantcast