Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Returning the number of decimals a field has
Message
De
14/08/2003 11:52:57
 
 
À
14/08/2003 10:40:31
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Divers
Thread ID:
00820138
Message ID:
00820174
Vues:
16
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
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform