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

FUNCTION MYTRANSFORM( aval, cmask )
LOCAL nDeci, cRes
nDeci = SET('deci')
SET deci to 10
cRes = TRANSFORM(m.aVal, m.cMask )
SET DECIMALS TO (m.nDeci)
RETURN m.cRes

>Transform() has several problems, and behaviour changes, since VFP 6 (the first version where it is supported without the second argument).
>
>I think you can use it safely for integers.
>
>However, if you need reliable results with transform() and decimals, better make your own version, as a UDF.
>
>Basic approach: use str() to specify a large number of decimals (perhaps 6, or 10); use strtran() to replace zeroes with spaces; use alltrim(); replace spaces back to zeroes.
>
>>
SET deci to 2
>>?TRANSFORM(1.12345,'999999.99999')
>>
>>Observed result
>>
>>1.12
>>
>>Expected result:
>>
>>1.12345
>>
>>occurs on : vfp 7, vfp 9 beta
>>
>>Is this VFP bug ?
Andrus
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform