Getting Windows thousands separator char?

Just starting out? Need help? Post your questions and find answers here.
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by PB.

As per the subject, I'd like to expand my "NiceNumber" procedure so that it uses
the default thousands separator of the machine's locale... any ideas?


PB - Registered PureBasic Coder
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by Paul.

Couldn't you do this to use the systems locale?

num.s="5545670"
result.s=" "
GetNumberFormat_(0,0,num,0,@result,255)
MessageRequester("",result,0)


Of course this kinda makes your procedure obsolete on Windows machines :(



Edited by - paul on 29 March 2002 20:13:19
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by PB.

> Of course this kinda makes your procedure obsolete on Windows machines :(

That's okay with me -- I only wrote the procedure because I didn't know
about the GetNumberFormat_() API! Thanks very much!

UPDATE: Unfortunately using GetNumberFormat_() is no good, because it adds
decimal "points" and extra digits if the user has them set in their Regional
Control Panel settings. It's too much hassle, and indeed not on, to get the
user to change their Regional settings, so I therefore still needed a way to
get the thousands separator character. I worked it out, as follows:

Code: Select all

; Thousands character has a maximum of 3 characters.
thou$="   " : GetLocaleInfo_(#LOCALE_USER_DEFAULT,#LOCALE_STHOUSAND,thou$,3)
Debug("Thousands character: "+thou$)

PB - Registered PureBasic Coder

Edited by - PB on 07 April 2002 20:24:31
Post Reply