>Hi,
>
>What i did was save the variable using sql to a dbf and use afield.
>
>Crude but it worked.
>
>
>
>>>Is there a command that returns the decimal precision of a variable?
>>>
You're using SQL's field mapping, actually; it's really using the minimal number of decimals it needs. Would you, please, try something like this:
x=3.005
x=x+x
Now measure the number of decimals for x with your method. You should get two decimal places, though x could have been three-decimaled for hours before this. If the number of decimals until the last non-zero digit is the issue, you may try this:
Func DecimalLen
Lpara x
Local DecString
decstring=str(x-int(x), 18,16)+space(1) && make it a number in a form of 0.xxxxxxxxxxxxx and add a space
do while "0 "$ decstring
decstring=strtran(decstring, "0 "," ") && replace any zero+space with just space, thus dropping one rightmost zero each time
endd
Return len(decstring-3) && take three for initial 0. and the trailing space
No cursors, no buffers, just a little UDF.