Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Alltrim for numeric variables
Message
 
 
To
18/06/2001 20:34:56
Dragan Nedeljkovich (Online)
Now officially retired
Zrenjanin, Serbia
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
00520367
Message ID:
00520839
Views:
15
Dragan,

I've never run into a roundoff/floating point kinda problem yet. If I'm dealing with a fixed sequence like field names I'm most likely to use PADL() anyway because the numeric part of the name ends up being fixed length with leading zeroes.

>>? ">" + transform( my_variable ) + "<" >
>
>Recently I had a nasty surprise with this. I had a loop to name the variables to use in a macro (because I had to loop through field1, field2, field3, ..., field45), and I used
>
cFieldName="field"+tran(i)
>where i was the loop counter. To my surprise, when it ran it banged on
>
cValue=eval(cFieldName)
>because the value in cFieldName was Field1.000000000 - probably the loop counter got created with some accidental (?) decimals. Luckily, I knew that the structure of the table will not change and that field1 is the 10th field, so I used
>
cValue=eval(fields(i+9))
>instead. Still, this accident got me thinking... will tran(integer) always yield a string representation of a number without a decimal point, or is it something to watch out for and code around.
df (was a 10 time MVP)

df FoxPro website
FoxPro Wiki site online, editable knowledgebase
Previous
Reply
Map
View

Click here to load this message in the networking platform