There is no problem at all using this function in multiple threads if you
don't need to change the Format Settings.  To quote from the D7
documentation.

 

The first form of FloatToStrF is not thread-safe, because it uses
localization information contained in global variables.

 

If you did change the global format settings such as DecimalSeparator so
that the decimal place was a comma as used in Europe, this would affect the
function being used in another thread.

 

Ross.

 

From: delphi-boun...@delphi.org.nz [mailto:delphi-boun...@delphi.org.nz] On
Behalf Of Vikas...
Sent: Thursday, 4 March 2010 7:03 p.m.
To: NZ Borland Developers Group - Delphi List
Subject: Re: [DUG] Need help in format function

 

well we are not using Multi threading in this case . This is a legacy system
and we have no plans to consider threading in it in future. Person who
programed it in 1997 dint considered any safe practices before, he just
worte in a fashion which serve the req of client.

Well intiitaly i was tying with fromat fuction but i dint served my purpose
then i moved to floattostrf this is not healthy functions in multi threaded
that i knew it.

But anyways like i said in previous mail my work arround made the bug to go
away and made my client stop complaing of the loses he occrured due to this 

But yeah i will re change it soon to optimise the way u guys sugguesting

thanks

On Thu, Mar 4, 2010 at 3:20 AM, Jolyon Smith <jsm...@deltics.co.nz> wrote:

Writing code that is thread-safe is still safe when there is only one
thread, but it sure does make things easier if/when you want to introduce
threads later on.  The only time that it makes sense to write code that is
knowingly not thread-safe is when you've made the conscious choice to write
single threaded code, but if the code is single threaded only because
threading has not even been considered (yet) .

 

The original poster may also have been simply unaware of the threading
issues with these functions.  Making assumptions is *always* dangerous.

 

 

From: delphi-boun...@delphi.org.nz [mailto:delphi-boun...@delphi.org.nz] On
Behalf Of Colin Johnsun
Sent: Thursday, 4 March 2010 10:35 a.m.


To: NZ Borland Developers Group - Delphi List
Subject: Re: [DUG] Need help in format function

 

I don't remember reading in the original post that Vikas needed the function
in a multi-threaded app?
In fact, the original FloatToStrF that Vikas used in his original post is
the non-threaded version, so I think it is reasonable to assume that he was
using it in a single threaded fashion. But thanks for pointing out how
useless Format ( Const Formatting  : string; Const Data  : array of const) :
string; is for multi-threaded situations.

Regards,
Colin

On 4 March 2010 08:07, Cameron Hart <cameron.h...@flowsoftware.co.nz> wrote:

And completely useless when it comes to multiple threads...

Atleast use the thread safe version

function Format ( Const Formatting  : string; Const Data  : array of
const; FormatSettings  : TFormatSettings ) : string;



Cameron Hart | Development Manager | Flow Software Limited
P: +64 9 476 3579 | M: +64 21 222 3569 | E:
cameron.h...@flowsoftware.co.nz
PO Box 305-237, Triton Plaza, Auckland 0757, New Zealand |
www.flowsoftware.co.nz

This message is intended for the addressee named above. It may contain
privileged or confidential information. If you are not the intended
recipient of this message you must not use, copy, distribute or disclose
it to anyone.

Please consider the environment before printing this email


-----Original Message-----
From: delphi-boun...@delphi.org.nz [mailto:delphi-boun...@delphi.org.nz]
On Behalf Of Colin Johnsun
Sent: Thursday, 4 March 2010 9:44 a.m.
To: NZ Borland Developers Group - Delphi List
Subject: Re: [DUG] Need help in format function

Hey Phil :)

You beat me too it!

It's clean, readable and concise.
Plus there's no mucking around with strings!!

+1 from me :)

cheers, Colin

On Thursday, March 4, 2010, Phil Scadden <p.scad...@gns.cri.nz> wrote:
> I think it easier to do format( '%.2f', [trunc(value*100)/100]);
>
>
> Notice: This email and any attachments are confidential. If received
in error please destroy and immediately notify us. Do not copy or
disclose the contents.
>
> _______________________________________________
> NZ Borland Developers Group - Delphi mailing list
> Post: delphi@delphi.org.nz
> Admin: http://delphi.org.nz/mailman/listinfo/delphi
> Unsubscribe: send an email to delphi-requ...@delphi.org.nz with
Subject: unsubscribe
>
_______________________________________________
NZ Borland Developers Group - Delphi mailing list
Post: delphi@delphi.org.nz
Admin: http://delphi.org.nz/mailman/listinfo/delphi
Unsubscribe: send an email to delphi-requ...@delphi.org.nz with Subject:
unsubscribe

_______________________________________________
NZ Borland Developers Group - Delphi mailing list
Post: delphi@delphi.org.nz
Admin: http://delphi.org.nz/mailman/listinfo/delphi
Unsubscribe: send an email to delphi-requ...@delphi.org.nz with Subject:
unsubscribe

 


_______________________________________________
NZ Borland Developers Group - Delphi mailing list
Post: delphi@delphi.org.nz
Admin: http://delphi.org.nz/mailman/listinfo/delphi
Unsubscribe: send an email to delphi-requ...@delphi.org.nz with Subject:
unsubscribe




-- 
 vikas

<<image001.gif>>

_______________________________________________
NZ Borland Developers Group - Delphi mailing list
Post: delphi@delphi.org.nz
Admin: http://delphi.org.nz/mailman/listinfo/delphi
Unsubscribe: send an email to delphi-requ...@delphi.org.nz with Subject: 
unsubscribe

Reply via email to