International Decimal Separator format problem
This is a general question but it applies to ReportBuilder too. Any help
would be appreciated.
I have a program that is used in several countries that have different
DecimalSeparator characters. The program writes ASCII files that contain
real values (numbers with decimal points).
Problems arise when an ASCII file written on one PC is read on another PC
that has a different DecimalSeparator character. The real values do not
convert to numbers.
How do I write a real number as a string in an ASCII file so that the file
can be read (and the real number string converted) on another PC with a
different DecimalSeparator? Should I only set the DecimalSeparator
character in my write procedures?
If I set the DecimalSeparator character at the start of my program will the
character remain constant within my program?
If I set the DecimalSeparator character at the start of my program will it
effect other programs running on the same PC?
Can another program change the DecimalSeparator character while my program
is running?
Must I reset the DecimalSeparator character back to the original character
at the end of my program?
Thanks
Bob Yeatman
would be appreciated.
I have a program that is used in several countries that have different
DecimalSeparator characters. The program writes ASCII files that contain
real values (numbers with decimal points).
Problems arise when an ASCII file written on one PC is read on another PC
that has a different DecimalSeparator character. The real values do not
convert to numbers.
How do I write a real number as a string in an ASCII file so that the file
can be read (and the real number string converted) on another PC with a
different DecimalSeparator? Should I only set the DecimalSeparator
character in my write procedures?
If I set the DecimalSeparator character at the start of my program will the
character remain constant within my program?
If I set the DecimalSeparator character at the start of my program will it
effect other programs running on the same PC?
Can another program change the DecimalSeparator character while my program
is running?
Must I reset the DecimalSeparator character back to the original character
at the end of my program?
Thanks
Bob Yeatman
This discussion has been closed.
Comments
1. Do not touch the country settings. If users decide to have a special
decimal separator they have a reason to do so.
2. Databases are able to handle this, if different users have access to the
same DB but have different country settings. This is true not only for
numbers, but dates too. But of course only if the fields are of type number,
date, ....
3. Writing to ASCII files, it is best to use a point as decimal separator.
Force this formatting in your app, so you can rely on this when reading the
data again. The same applies to dates BTW. (The point is better than a
semicolon, because the semicolon is a field separator too.)
Some more answers inline:
See above. Try to NOT alter the DecimalSeparators.
the
Yes, unless some other part of your program (3rd party lib) changes it.
Depends on how you set the DecimalSeparator. Read the Delphi help on this.
Yes.
It is good habit to do so. Even if the change was local to your app.
BTW: We have had troubles using TerminalServer. In about 12% of the app
starting the locale settings were wrong......
So again: try to not change the locales.
Good luck
--
Bernd Maierhofer
No private unless requested, please.