Determine decimal seperator on system

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

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
Garrett
Posts: 386
Joined: Sat Apr 08, 2006 8:15 am
Contact:

Determine decimal seperator on system

Post by Garrett » Mon Sep 21, 2009 5:42 am

I'd like to know if there's a way to determine the decimal separator for any given system and platform that my program may be working on.

When doing division I need to find out what character is being used as the decimal character. I know in the USA we use a period and from what I understand, in the UK a comma is used.

Does anyone know if there is a way to determine what character is being used for the decimal?

Thanks,
~Garrett
'What you do not want done to yourself, do not do to others.' - Confucius (550 b.c. to 479 b.c.)

dickey
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 118
Joined: Wed Apr 08, 2009 11:54 pm

Determine decimal seperator on system

Post by dickey » Mon Sep 28, 2009 12:09 am

Hello Garrett,

I hate to see a question go 43 views without an attempt to answer it.

You can query, delete from, and add to the Windows Registry from within Revolution by accessing reg.exe via the shell (a link I found quite useful was http://commandwindows.com/reg.htm). Reg.exe (the cmd line registry editor is nearly always present with the exception of some MS 'Home' branded versions of Windows. Where it is not present there is no barrier from installing it with your app. From memory - I believe the separators like decimal or digit grouping are located under the HKEY_CURRENT_USER\Control Panel\International path in the registry.

For OSX I am unsure.

I hope this helps a little.

Kind regards,

Andrew

Garrett
Posts: 386
Joined: Sat Apr 08, 2006 8:15 am
Contact:

Post by Garrett » Mon Sep 28, 2009 6:14 am

Thanks a bunch Dickey :-)
'What you do not want done to yourself, do not do to others.' - Confucius (550 b.c. to 479 b.c.)

bn
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 4174
Joined: Sun Jan 07, 2007 9:12 pm

Post by bn » Mon Sep 28, 2009 6:56 pm

Garrett,

since nobody is coming up with a better solution for the mac you could do it with a little applescript:

Code: Select all

   put "set userDecimalSeparator to item 2 of (1.1 as string)" & return & "return userDecimalSeparator" into WhatIsTheSeparator
   do WhatIsTheSeparator as applescript
   put the result into tDecimalSeparatorMac
   replace quote with empty in tDecimalSeparatorMac
   -- tDecimalSeparatorMac now contains the user's decimal separator as in his system preferences
   -- now you can test for that and adjust the thousand separator accordingly
As far as I know there is either a "," or a "." as decimal separator. And the thousand separator is either "." or ",".
regards
Bernd

Garrett
Posts: 386
Joined: Sat Apr 08, 2006 8:15 am
Contact:

Post by Garrett » Tue Sep 29, 2009 2:12 am

Thanks Bernd :-)
'What you do not want done to yourself, do not do to others.' - Confucius (550 b.c. to 479 b.c.)

Post Reply