PROCEDURE RemoveDecimals (nNumber as number)
* be aware, the number is retured as a string!!!! without trailing zero's
PRIVATE nNewNumber, nCounter, cNewNumber, nSetDecimals
nSetDecimals = SET('Decimals')
nNewNumber = nNumber - INT(nNumber)
cNewNumber = STR(nNumber, 10,3)
* how many decimals does this number have?
cNewNumber = ALLTRIM(STR(nNewNumber,20,10))
FOR nCounter = LEN(cNewNumber) TO 1 STEP -1
IF SUBSTR(cNewNumber,nCounter,1) = SET('POINT') OR SUBSTR(cNewNumber,nCounter,1) <> '0'
EXIT && loop
ENDIF
ENDFOR
IF nCounter > 1
cDecimals = SUBSTR(cNewNumber, 1, nCounter)
* drop the 0. infront of the number
cDecimals = SUBSTR(cDecimals, 3,LEN(cDecimals))
IF LEN(cDecimals) > 0
cNewNumber = ALLTRIM(STR(INT(nNumber),10,0)) + SET('POINT') + cDecimals
ELSE
cNewNumber = ALLTRIM(STR(INT(nNumber),10,0))
ENDIF
ENDIF
SET DECIMALS TO nSetDecimals
RETURN (cNewNumber )
>RTRIM(RTRIM(TRANSFORM(1000.000, "999,999.999"), "0"), ".") >