Icon View Thread

The following is the text of the current message along with any replies.
Messages 1 to 8 of 8 total
Thread FloatToStr, separator char
Thu, Jan 10 2013 10:46 AMPermanent Link

Enrico Lago

Hi, I have a problem with a float value. The program uses comma as decimal separator. All works well in a italian machine but not in a english machine. How can I know before store a value in a table if dbisam wants dot and not comma as separator char?
Thu, Jan 10 2013 11:43 AMPermanent Link

Roy Lambert

NLH Associates

Team Elevate Team Elevate

Enrico

>Hi, I have a problem with a float value. The program uses comma as decimal separator. All works well in a italian machine but not in a english machine. How can I know before store a value in a table if dbisam wants dot and not comma as separator char?

Would checking the value of DecimalSeparator work? Delphi uses the Windows settings and I think DBISAM does the same.

Roy Lambert [Team Elevate]
Thu, Jan 10 2013 6:49 PMPermanent Link

Malcolm Taylor

Enrico Lago wrote:

> Hi, I have a problem with a float value. The program uses comma as
> decimal separator. All works well in a italian machine but not in a
> english machine. How can I know before store a value in a table if
> dbisam wants dot and not comma as separator char?

Enrico

The database stores floats in a standard (binary) format unless you are
using character types.

The decimal separator is a matter of 'presentation'.  
Input and output operations use the decimal separator (as well as
differing date, time, etc, formats) chosen by the user.

So the general advice is that you should not make assumptions about the
decimal separator or the way dates, etc, are entered or displayed.
Just process the data using the appropriate data types and most of the
problems go away.

Admittedly there may be some situations in which you may have to
'force' a particular format.
In my case, for example, I exchange CSV files across the World so I
make sure that all my CSV files use a decimal point for floats and then
I can convert to/from the local user's format by reference to their
Format Settings.

Malcolm
Fri, Jan 11 2013 3:57 AMPermanent Link

Enrico Lago

>
>The database stores floats in a standard (binary) format unless you are
>using character types.
>
The situation is a client - server application. In this case the OS of the server is in English and the clients are in Italian language.
I have used on server and on client this row
"FormatSettings.DecimalSeparator:= ',';" for get comma as separator char.
Now I see that the server, sometimes, is not able to write in the database a value with comma as separator.
The normal situation is clients and server in Italian language. In this contest all works well.
How can I obtain the separator char that dbisam wants before the insert?
Fri, Jan 11 2013 7:19 AMPermanent Link

Malcolm Taylor

Enrico Lago wrote:

> The situation is a client - server application. In this case the OS
> of the server is in English and the clients are in Italian language.
> I have used on server and on client this row
> "FormatSettings.DecimalSeparator:= ',';" for get comma as separator
> char.  Now I see that the server, sometimes, is not able to write in
> the database a value with comma as separator.  The normal situation
> is clients and server in Italian language. In this contest all works
> well.  How can I obtain the separator char that dbisam wants before
> the insert?

Unfortunately I switched from DBISAM to EDB several years ago so I
can't easily test.

Short of maintaining a configuration setting with the decimal separator
used by a server, I wonder if it is possible to avoid having to format
your INSERT statements?

Totally untested!  
Can you use a MEMORY table to temporarily save new record(s) on the
local machine (no locale issues), then do something like (can't
remember exact DBISAM syntax):
   INSERT INTO <server table> SELECT * FROM <memory table>
   ... delete from memory table if successful ...

Maybe Tim or some other expert can comment?

Malcolm
Fri, Jan 11 2013 7:41 AMPermanent Link

Uffe Kousgaard

"Malcolm" <malcolm@spam.will.bounce> wrote in message
news:16EBAB83-0B33-42CB-BCB1-
>
> Short of maintaining a configuration setting with the decimal separator
> used by a server, I wonder if it is possible to avoid having to format
> your INSERT statements?

INSERT statements should not be localized, that means use . as decimal point
etc.

Fri, Jan 11 2013 9:52 AMPermanent Link

Malcolm Taylor

Uffe Kousgaard wrote:

>
> INSERT statements should not be localized, that means use . as
> decimal point etc.

Thanks Uffe, I thought that was the case but could not check it.
Fri, Jan 11 2013 10:44 AMPermanent Link

Tim Young [Elevate Software]

Elevate Software, Inc.

Avatar

Email timyoung@elevatesoft.com

Enrico,

<< Hi, I have a problem with a float value. The program uses comma as
decimal separator. All works well in a italian machine but not in a english
machine. How can I know before store a value in a table if dbisam wants dot
and not comma as separator char? >>

If you're specifying values in SQL statements or filters, then DBISAM always
uses the period (.) as the decimal separator in SQL/filters:

http://www.elevatesoft.com/manual?action=viewtopic&id=dbisam4&product=delphi&version=7&topic=Naming_Conventions

under "Date, Time, TimeStamp, and Number Constants".

If you have any other questions, please let me know.

Tim Young
Elevate Software
www.elevatesoft.com
Image