Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
TRANSFORM() depends on SET DECIMAL. Bug?
Message
De
21/07/2004 12:12:51
Hilmar Zonneveld
Independent Consultant
Cochabamba, Bolivie
 
 
À
21/07/2004 11:59:16
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Divers
Thread ID:
00926580
Message ID:
00926601
Vues:
18
>I create the following fixed transform() function.
>Will this work OK always ?

I can't guarantee that it will; I recommend the approach I told you before.

In VFP6, for instance, for transform(-9.2) I am getting "-9,199999999999999". The situation gets worse if I use variables; probably due to rounding errors. This issue was supposedly resolved in later versions; but I think that other issues appeared.

OTOH, padl() seems to be more reliable; for instance, alltrim(padl(-9.2, 20)) gives me the expected "-9,2".

And yet, I would prefer to place my trust in a UDF. Here is a quick version of the function that uses the principle I explained in my previous message:
function MyTransform
	* Solve problems with transform() function
	lparameters tnNumber
	return strtran(alltrim(strtran(str(tnNumber, 20, 10), "0", " ")), " ", "0")
endfunc
You may want to enhance it so that it shows, for example, "0,3" instead of ",3".

HTH,

Hilmar.
Difference in opinions hath cost many millions of lives: for instance, whether flesh be bread, or bread be flesh; whether whistling be a vice or a virtue; whether it be better to kiss a post, or throw it into the fire... (from Gulliver's Travels)
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform