Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Returning the number of decimals a field has
Message
From
14/08/2003 12:57:26
 
 
To
14/08/2003 12:49:56
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
00820138
Message ID:
00820223
Views:
19
>>>Is there a function that will return how many decimal places a numberic field has? Something like LEN() for a character field. I know I can get it with AFIELDS but I only want to check one field and this returns all the fields then I need to find what the field number is in the array. Seems like a pain for something this simple.
>>
>>
Function DecCount(tnVal)
>>Local n
>>cVal = Alltrim(Padl(tnVal, 1000))
>>
>>Return Len(cVal - IIF(At('.', cVal) = 0, Len(cVal), At('.', cVal))
>>
>>? DecCount(AliasName.FieldName)
>>
>>Alan
>
>Thanks I shorted it down to

I need to add the MAX function for whole numbers
ln_dec = MAX(LEN(TRIM(PADR(MOD(field, 1), 21))) - 2, 0)
Charles

"The code knows no master." - Chuck Mautz
"Everybody is ignorant, only on different subjects." - Will Rogers
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform