[Webinar] Streamline your web hosting managementRegister Today

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 658
  • Last Modified:

How to avvoid international decimal point problems

I was running my application which had originally been built on a Computer with English setup on a Norwegian one, where the decimal point is "," (comma) and not "." (point).

Therefore my application produced an error saying that "7.5" was not a correct Float.

Changing the International settings to English (US) and rebooting solved the problems - but there must be an internal and better way to solve the problem in Delphi.

Isn't it?
0
bjornborg
Asked:
bjornborg
  • 3
  • 2
  • 2
1 Solution
 
MotazCommented:
But '.' in DecimalSeparator variable:

DecimalSeparator:= '.';

This will ignore system's current settings
Motaz
0
 
kretzschmarCommented:
seems you've a hardcoded interpunction in this app

normally, the numberformatting depends on the local-regional settings.

to get it work you can adjust applicationwide the interpunction at startup of your app

well, have this not in mind which exact,
but look into the delphi online-help
(as entry you could search for shortdateformat
(well its not this what you a searching, but after you've find it you will also see the variablnames for the interpunction))

meikl ;-)
0
 
kretzschmarCommented:
thanks motaz :-)
0
Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

 
bjornborgAuthor Commented:
Thank you, in this case I get the value from an external program, and I guess I can do a Find/Replace on the string that I receive (e.g '7.5') before I convert it to a Float.

I have seen another message somewhere that there is a way to read the international settings from the System.

BUT: It must be possible to modify the way Delphi is supposed to understand external input to make sure that even "wrong" number values are interpreted correctly ??

0
 
bjornborgAuthor Commented:
..oops: I guess the solution is what Motaz was suggesting - will have to try that when I am back on my machine with Delphi again to try using "DecimalSeparator"
0
 
bjornborgAuthor Commented:
I found the "DecimalSeparator" settings in the BDE Administrator tool, but this is not really what I was looking for.

In my case I am not using a database, but I receive the number (as a string) from another application. What I would like Delphi to be able to do, is to be able to understand the input (no matter which setting the PC has) so that 7.5 is accepted as a number even when run on a machine with European setup.

In my previous world I used to be able to define application.decimalseparator, and this would override the PCsystem.decimalseparator settings.

Bjorn
0
 
MotazCommented:
I mean DecimalSeperator global variable, just write:

DecimalSeperator:= '.'; at OnCreate event of your main form.
0

Featured Post

Receive 1:1 tech help

Solve your biggest tech problems alongside global tech experts with 1:1 help.

  • 3
  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now