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 11:52:57
 
 
To
14/08/2003 10:40:31
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
00820138
Message ID:
00820174
Views:
17
Hi Chuck.

>Is there a function that will return how many decimal places a numberic field has?

If the table is open, you could use something like (where FIELDNAME is the name of the field):
lcValue    = transform(FIELDNAME)
lnPlace    = at('.', lcValue)
lnLen      = len((lcValue)
lnDecimals = iif(lnPlace = 0, 0, lnLen - lnPlace)
This is actually more code than using Mark's suggestion of AFIELDS, which can be reduced to the admittedly dense {g}:
afields(laFields)
lnDecimals = laFields[ascan(laFields, 'FIELDNAME', -1, -1, 1, 15), 4]
Doug
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform