Subject | Re: [firebird-support] Re: [ib-support] to change the decimal separator |
---|---|
Author | Alexandre Benson Smith |
Post date | 2006-08-30T05:26:16Z |
aandea_launch wrote:
Multi-thread... :-) I suspected this, but I won't consider that code
snippet as rock solid, it has no provision for even handle any kind of
exception. :-)
My app is single threaded.
Anyway, one could put a lock before the try and unlock on the finally to
signal no other thread should change de decimal separator.
a lot of other sollutions are ok too like
function FloatToStrSQL(D:Extended):String;
begin
Result := StringReplace(FloatToStr(D), '.', ',' [rfReplaceAll]);
end;
see you !
--
Alexandre Benson Smith
Development
THOR Software e Comercial Ltda
Santo Andre - Sao Paulo - Brazil
www.thorsoftware.com.br
> Hello Alexandre ,ahhh..
>
> The danger in using this function :
>
> function FloatToStrSQL(D:Extended):String;
> var
> wDecimalSeparator:Char;
> begin
> wDecimalSeparator := DecimalSeparator;
> DecimalSeparator := '.'
> try
> Result := FloatToStr(D);
> finally
> DecimalSeparator := wDecimalSeparator;
> end;
> end;
>
> is in multi-threaded envrionments, where one thread might set the
> separator back before you are doing the conversion in other thread...
>
Multi-thread... :-) I suspected this, but I won't consider that code
snippet as rock solid, it has no provision for even handle any kind of
exception. :-)
My app is single threaded.
Anyway, one could put a lock before the try and unlock on the finally to
signal no other thread should change de decimal separator.
a lot of other sollutions are ok too like
function FloatToStrSQL(D:Extended):String;
begin
Result := StringReplace(FloatToStr(D), '.', ',' [rfReplaceAll]);
end;
see you !
--
Alexandre Benson Smith
Development
THOR Software e Comercial Ltda
Santo Andre - Sao Paulo - Brazil
www.thorsoftware.com.br