Regional settings and Delphi compiled code

Giganews Newsgroups
Subject:Regional settings and Delphi compiled code
Posted by: Paul Hewett (phewe…@oesh.com)
Date:Thu, 28 Sep 2006

I have written a program originally intended only for users in the US and
UK.  I am trying to sort out the issues when it is used in countries where
the comma, rather than a period, is used to separate the whole number from
the fractional part of a value.

I use the following code in a procedure that checks if the number (i.e.,
text) in an edit component is a valid number:

val( str, value, error );    // str = Edit.text and value is a double
variable
if (error<>0) then {display  a warning to the user}

When I change the Regional Settings to "French (Belgium)" my spreadsheet
uses the commo as the separator as expected. However, the val(...) function
above generates a non-zero error, which means that the str, such as '10,3' ,
was not valid for conversion to a number.  When I switch back to the US
setting the procedure works fine, converting '10.3' to a number as expected.

"Any" help would be appreciated.  I could find "nothing" helpful in my
several hundred dollars worth of Delphi texts on the topic of
"internationalizing" a Delphi application.

Paul

Replies