Page 1 of 1

Decimal point delimiter

Posted: Thu May 05, 2011 1:52 pm
by andyh1234
Im used to seeing a . for the decimal point delimiter, but a user has written to say a comma is used in many countries instead.

Is it possible to easily pick up the system setting for the delimiter in both Windows and Mac, and have Livecode display numbers using that delimiter rather than default to the .?

Thanks

Re: Decimal point delimiter

Posted: Fri May 06, 2011 9:28 am
by Mark
Hi Andy,

In my country, the Netherlands, we use the comma instead of the dot, just like all over continental Europe. There is no easy way to accommodate this in Rev. If I have to use a the comma as the decimal delimiter in Rev, I do the calculations with the dot and replace the dot with a comma only when I'm going to display the result.

Kind regads,

Mark

Re: Decimal point delimiter

Posted: Fri May 06, 2011 10:23 am
by SparkOut
You can make the display of decimal dot or comma choice reasonably painless by always working in the dot format internally and using a setProp handler to trigger a reformatting according to the choice before the value is put into a field.

You could adapt something from this discussion to achieve the results needed, perhaps: http://forums.runrev.com/phpBB2/viewtop ... 704#p12704

To get the system settings for what the current user's decimal separator looks like from within Livecode is not easy though, as Mark says. I don't believe there is anything built in that Livecode includes (as one of its globals) that it would be possible to use to retrieve it. On Windows 7, you can interrogate the registry key HK_CURRENT_USER\Control Panel\International and find the entry for sDecimal. I'm unable to check at the moment with earlier versions of Windows whether it is the same key. For Mac OS X, Linux or any mobile flavour... no idea, sorry.

Re: Decimal point delimiter

Posted: Fri May 06, 2011 12:10 pm
by andyh1234
Thanks, the setprop in the other thread will work and Im guessing Ill need a getprop as well as the user will almost certainly use the comma when entering values if it is shown.

Ill try to figure out how to get the system setting on a mac, it must be possible with a shell command of some kind.

Thanks again.

Andy