Welcome! Log In Create A New Profile

Advanced

ChangeSeparator( ... )

Posted by gpredl 
ChangeSeparator( ... )
August 20, 2021 04:31PM
Hi,

for changing / setting the decimal separator and the thousands separator WINDEV offers the function ChangeSparator( .. ) It seems to a very old thing (maybe from 5.5 ?) because it's activated by a USE statement. I couldn't make it work. Until now I'm still using a procedure

PROCEDURE FindDecimalSeparator()
MAX_BUFFER_SIZE is 2-byte int=100
LOCALE_USER_DEFAULT is 4-byte int=1024
LOCALE_SMONDECIMALSEP is 4-byte int=22

mApiReturn is 4-byte int
mBuffer is string
mBufferSize is 4-byte int

mBuffer = RepeatString(Charact(0),MAX_BUFFER_SIZE)
mBufferSize = MAX_BUFFER_SIZE - 1

mApiReturn = CallDLL32("kernel32","GetLocaleInfoA",LOCALE_USER_DEFAULT,LOCALE_SMONDECIMALSEP,&mBuffer,mBufferSize)
mBuffer = Left(mBuffer,mApiReturn - 1)

RESULT mBuffer

As I can see, GetLocaleInfoA( ... ) is already old too, but it still works in 32-bit and 64-bit Windows. I did not succeed with the newer funktions.

Kind regards,
Guenter Predl
office@windev.at
Re: ChangeSeparator( ... )
August 21, 2021 01:03PM
Hi Guenter,

this works for me across all WD versions:

// Parameters come from a configuration table/record
a360_sThousandSign is string = gConfiguration.sDecimalSign
a360_sNumberSign is string = gConfiguration.sThousandSign

// Change Separators ..
ChangeSeparator(sepDECIMAL , a360_sThousandSign)
ChangeSeparator(sepTHOUSAND , a360_sNumberSign)

Regards
Steven Sitas
Re: ChangeSeparator( ... )
August 23, 2021 07:14AM
Hi Steve, thank you!

I hope that ChangeSeparator(..) is actually doing it's job - to change the separator - but it does not read the current ones. To make things more clear to myself and the forum, I'll create a demo to show the use and limits of manipulating the decimal separator in input / display, NumtoString(..) and reports.

Kind regards,
Guenter Predl
office@windev.at
Re: ChangeSeparator( ... )
August 23, 2021 09:48AM
Hi Guenter,

the following should work for getting the current DECIMAL separator:

nTemp is numeric = 2.11
sTemp is string = NumToString(nTemp, maskSystemNumeral)
// Now use the string functions to find the DECIMAL Separator

You can use the same technique for the THOUSANDs separator

Regards
Steven Sitas
Author:

Your Email:


Subject:


Spam prevention:
Please, enter the code that you see below in the input field. This is for blocking bots that try to post this form automatically. If the code is hard to read, then just try to guess it right. If you enter the wrong code, a new image is created and you get another chance to enter it right.
Message: