Decimal point delimiter

Anything beyond the basics in using the LiveCode language. Share your handlers, functions and magic here.

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
andyh1234
Posts: 476
Joined: Mon Aug 13, 2007 4:44 pm
Contact:

Decimal point delimiter

Post by andyh1234 » Thu May 05, 2011 1:52 pm

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

Mark
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 5150
Joined: Thu Feb 23, 2006 9:24 pm
Contact:

Re: Decimal point delimiter

Post by Mark » Fri May 06, 2011 9:28 am

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
The biggest LiveCode group on Facebook: https://www.facebook.com/groups/livecode.developers
The book "Programming LiveCode for the Real Beginner"! Get it here! http://tinyurl.com/book-livecode

SparkOut
Posts: 2949
Joined: Sun Sep 23, 2007 4:58 pm

Re: Decimal point delimiter

Post by SparkOut » Fri May 06, 2011 10:23 am

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.

andyh1234
Posts: 476
Joined: Mon Aug 13, 2007 4:44 pm
Contact:

Re: Decimal point delimiter

Post by andyh1234 » Fri May 06, 2011 12:10 pm

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

Post Reply