Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Bug? in VAL on Currency strings
Message
 
À
26/06/2000 11:19:37
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Divers
Thread ID:
00384678
Message ID:
00384733
Vues:
25
Tom,

I think it happens because FoxPro can properly recognize numbers having not more than 20 positions. Because of currency $ sign they are 19 for currency.

Yuri

*-----------------your message below

I'm using XML to send some data around, and (unrelated to XML) found the following oddity converting the strings back to data in my table.

The string is created using TRANSFORM on a currency field from a query cursor.

You can repeat the problem on the command line as follows:
x = '$20,650.000000000000000000' && output of Transform
?Val(x) && gives 21 due to trunc of Val at the comma, as expected

x1 = strtran(x,',')
?x1 && gives '$20650.000000000000000000'
?val(x1) && gives 20660.0000 && WRONG VALUE!!
?vartype(val(x1)) && gives 'Y'

It is not invariably 10 off, sometimes it is 1 off (it seems to be always higher, and I've only seen 10 and 1 offsets)

I have not tested this exhaustively, but it seems to convert numbers below 10000 OK (no effect of the strtran)

If I also remove the '$' at the beginning, it converts properly, but to a Number type:
x2 = strtran(x1, '$') && gives '20650.000000000000000000'
?val(x2) && gives 20650.00 type 'N'

If I remove the excess decimal zeros from a Currency perspective it also works:

x3 = Substr(x1,1,at('.',x1)+4) && gives '$20650.0000'
y3 = val(x3) && 20650.0000
?vartype(y3) && 'Y'

Can anyone explain this? Is there some weird interaction with SET DECIMALS or something? I can go either route to fix the problem, but I'd like to understand any possible side effects.

Thanks,
Tom
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform