TStringList.SetCommaText needs refactor

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

TStringList.SetCommaText needs refactor

Free Pascal - General mailing list
It's obvious this needs to use SetDelimetedText with other params (2nd 3rd)

Procedure TStrings.SetCommaText(const Value: string);
begin
   CheckSpecialChars;
   C1:=Delimiter;
   C2:=QuoteChar;
   Delimiter:=',';
   QuoteChar:='"';
   Try
     SetDelimitedText(Value);
   Finally
     Delimiter:=C1;
     QuoteChar:=C2;
   end;
end;


it's obvious this needs to be changed too:

procedure TStrings.AddCommaText(const S: String);
var
   L: TStringList;
begin
   L := TStringList.Create;
   try
     L.CommaText := S;
     AddStrings(L);
   finally
     L.Free;
   end;
end;


--
Regards,
Alexey

_______________________________________________
fpc-pascal maillist  -  [hidden email]
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: TStringList.SetCommaText needs refactor

Michael Van Canneyt

Please create bugreports.

Michael.

On Sat, 9 Nov 2019, AlexeyT via fpc-pascal wrote:

> It's obvious this needs to use SetDelimetedText with other params (2nd 3rd)
>
> Procedure TStrings.SetCommaText(const Value: string);
> begin
>   CheckSpecialChars;
>   C1:=Delimiter;
>   C2:=QuoteChar;
>   Delimiter:=',';
>   QuoteChar:='"';
>   Try
>     SetDelimitedText(Value);
>   Finally
>     Delimiter:=C1;
>     QuoteChar:=C2;
>   end;
> end;
>
>
> it's obvious this needs to be changed too:
>
> procedure TStrings.AddCommaText(const S: String);
> var
>   L: TStringList;
> begin
>   L := TStringList.Create;
>   try
>     L.CommaText := S;
>     AddStrings(L);
>   finally
>     L.Free;
>   end;
> end;
>
>
> --
> Regards,
> Alexey
>
> _______________________________________________
> fpc-pascal maillist  -  [hidden email]
> https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
>
_______________________________________________
fpc-pascal maillist  -  [hidden email]
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal