Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Function to retrieve Decimal Places
Message
De
30/06/2009 10:57:41
 
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Divers
Thread ID:
01409350
Message ID:
01409365
Vues:
71
>Yuri:
> Thanks. I thought about that, but I'd really like to just do everything in one step, without having to use an array.
>
>Jerry


Try this - it won't work if total # of digits > 18 - as it then switches to scientific notation (eg 1e19)
create cursor pp ;
	(	field1 N(6,2), ;
		field2 b(6) ;
	) 
	append blank
	
	?Number_Digits_FractionalPart(field1 )
	?Number_Digits_FractionalPart(field2 )

function Number_Digits_FractionalPart(n)
	
	if( !inlist(vartype(m.n), T_NUMERIC, T_CURRENCY, T_FLOAT, T_DOUBLE) )
		assert FALSE
		return 0
	
	endif

	return len(rtrim(justext(strtran(padl(m.n, 30), set('point'), '.'))))	
endfunc
*---------------------------------------------------------------------------
Gregory
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform