Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Simple Transform() Problem
Message
 
 
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Divers
Thread ID:
00838401
Message ID:
00839981
Vues:
19
>>It works correctly in VFP 6.

Andy and Scott,

I can't check this in 6, but believe it or not I have VFP5 loaded <s>.

Somewhere around 7 TRANSFORM() was changed so that you didn't need the extra arguments, which would have included a picture for numeric data. I don't really remember whether it was VFP 6 or 7 that saw this change.

At any rate, if I'm right that this changed in 7, then VFP 6 couldn't possibly have processed TRANSFORM(4.220) -- you would have gotten a "too few arguments" error. That's definitely what you get from 5 and earlier versions <s>.

If the change occurred in 6 and VFP 6 did what you say (gave you back 4.22 for TRANS(4.220) )then this would be a bug in the recently-implemented behavior in 6, according to the documentation of this new behavior.

Without a picture, you should get a string back exactly the decimal places you put in, including 0's -- unless SET FIXED is on.

SET DECIMALS TO 8
SET FIXED OFF
? TRANSFORM(4.2260) && gives you 4.2260
SET FIXED ON
? TRANSFORM(4.2260) && gives you 4.22600000
SET DECIMALS TO 1
SET FIXED OFF
? TRANSFORM(4.2260) && gives you 4.2260
SET FIXED ON
? TRANSFORM(4.2260) && gives you 4.2

... in both 7 and 8.

The behavior of TRANSFORM() with a picture is much older, and a lot murkier <s>.

I believe that, yes, as a display function, TRANS() with a picture does respect the setting of SET("DECIMALS") and does not respect whether SET("FIXED") is ON or OFF. The picture, not SET("FIXED"), is used to determine how many places should exist after SET("DECIMALS") determines how the number should be truncated.

The important thing to remember is that this function does not unilaterally truncate. It uses SET("DECIMALS") to figure out how to shorten the number and then if the picture requires it pads. The picture is taking precedence over any setting of FIXED.

This isn't new. FoxPro for DOS 2.6 does exactly the same thing <s>. Therefore I can't classify it as a bug.

You may prefer to use the STR() function in some instances.

I'm writing quickly and am probably making a hash of explaining this, but HTH,

>L<
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform