Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Returning the number of decimals a field has
Message
 
 
À
14/08/2003 11:52:57
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Divers
Thread ID:
00820138
Message ID:
00820187
Vues:
21
That was quite dense, and I would split up the RETURN line for readability. < g > Plus your results can be defeated by the actual value in the field. In the Invoices table in the NW DBC, I get no decimals using TRANSFORM() on the discount field regardless of the overall value of the field unless at least one of the decimal places has at least 1 non-zero value.

>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
Mark McCasland
Midlothian, TX USA
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform