Welcome! Log In Create A New Profile

Advanced

How to not format decimal

Posted by ccc2 
ccc2
How to not format decimal
July 17, 2019 10:03AM
I have value price in db float , in wd real.
if there is decimal , I want to display out without trailing zero. if no decimal value , I want show just the integer value

for example
in DB 1,200.500000
display in table column as 1,200.5

in DB 1,200.000000
display in table column as 1,200

in DB 0.12300
display in table column as 0.123


is there build in function in WD that allow me do this ? in try numtostring() but unable do it
Re: How to not format decimal
July 17, 2019 10:32AM
Hi ccc2,

there are the masks for you! You can build the DisplayMask and the InputMask according to your needs:

// Preis in Table_LZ: Nachkommastellen setzen
IF KUNDEN.KUPREISLISTE > 0 THEN
IF HReadSeekFirst(PRLNAME,PN_NUM,KUNDEN.KUPREISLISTE) THEN
IF PRLNAME.PN_NACHKOMMAST = 3 THEN
TABLE_LZ.LZ_PREIS..DisplayMask = "+99999"+DezimalTrennzeichen+"999"
EDIT6..DisplayMask = "+99999"+DezimalTrennzeichen+"999"
EDIT6..InputMask = "+99999"+DezimalTrennzeichen+"999"
ELSE
TABLE_LZ.LZ_PREIS..DisplayMask = "+99999"+DezimalTrennzeichen+"99"
EDIT6..DisplayMask = "+99999"+DezimalTrennzeichen+"99"
EDIT6..InputMask = "+99999"+DezimalTrennzeichen+"99"
END
END
END

The variable DezimalTrennzeichen is comma or dot according to settings of the operating system. You can retrieve it using a small procedure:

PROCEDURE FindeAktDezTrenner()
MAX_BUFFER_SIZE is 2-byte int=100
LOCALE_USER_DEFAULT is system int=1024
LOCALE_SMONDECIMALSEP is system int=22

mApiReturn is system int
mBuffer is string
mBufferSize is system 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

Kind regards,
Guenter Predl
office@windev.at
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: