And this is a more polished version:
function noZ*****rail(pcNumber)
local lnDummy, lnDecimals
lnDecimals = set("decimals")
set Decimals to 18
if varType(pcNumber) # "C"
pcNumber = tran(pcNumber)
endIf
lnDummy = val(pcNumber)
pcNumber = tran(lnDummy)
if lnDummy%1 # 0
pcNumber = chrtran(allt(chrtran(tran(pcNumber),"0"," "))," ","0")
endIf
set Decimals to (lnDecimals)
return pcNumber
"Giancarlo Piccinato" <piccinato@[EMAIL PROTECTED]
> wrote in message
news:%23yXPWrgqHHA.4280@[EMAIL PROTECTED]
> Not exactly.
> This should get you started:
>
> function noZ*****rail(pnNumber)
> local lnLen, i, lnDummy, lnDecimals, lcDummy
> lnDecimals = set("decimals")
> set Decimals to 18
> if pnNumber%1 # 0
> lcDummy = tran(pnNUmber)
> lnLen = len(lcDummy)
> do while right(lcDummy,1) == "0"
> lnLen = lnLen - 1
> lcDummy = left(lcDummy,lnLen)
> endDo
> else
> lcDummy = tran(pnNumber)
> endIf
> set Decimals to (lnDecimals)
> return lcDummy
>
> HTH,
>
> Giancarlo
>
> "Dan Freeman" <spam@[EMAIL PROTECTED]
> wrote in message
> news:u4ZChggqHHA.4180@[EMAIL PROTECTED]
>> ?Transform(Int(value))
>>
>> Dan
>>
>> Gene Wirchenko wrote:
>>> How do I print a number in simplest form?
>>>
>>> The numbers I have are specifed to two decimal places, but I do
>>> not want trailing 0's or decimal point. (I allow input of two decimal
>>> places, but the precision does not need to be printed.)
>>>
>>> transform(5.30) gives "5.30", and I want "5.3".
>>> transform(5.00) gives "5.00", and I want "5".
>>>
>>> I also do not want any leading spaces. I can ltrim() for that
>>> though.
>>>
>>> I get a surprising result with overprecise constants:
>>> n=5.3000
>>> ? transform(n) && outputs "5.3000"
>>> n=5.30
>>> ? transform(n) && outputs "5.30"
>>> n=5.00
>>> ? transform(n) && outputs "5"
>>> I expected "5.00" from the last.
>>>
>>> What is the easiest way to deal with this?
>>>
>>> Sincerely,
>>>
>>> Gene Wirchenko
>>>
>>> Computerese Irregular Verb Conjugation:
>>> I have preferences.
>>> You have biases.
>>> He/She has prejudices.
>>
>>
>


|