Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Numeric string or not?
Message
 
To
21/03/2001 20:28:40
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
00487462
Message ID:
00488083
Views:
11
David,

You are right. I guess you can ask for type and vartype, but still you'll have (at least) the problem with formulas leading to numbers. But for the a123 case you can ask for type(x)='N' and vartype(x)='U'. And may be you can also include Marcia's suggested function to filter out letters (Although the letter E is valid for numbers, if only appears once and not at the beginning of the number or inmmediately after the point)

Hugo


>>Probably i'm missing something, but,
>>if x='1.2' then: type(x)='N'
>>if x='1.a' then: type(x)='U'
>

>
>This almost works but fails in subtle cases.
>
>Suppose:
>
>a123 = 456
>
>if x='123' then: type(x) = 'N'
>if x='a123' then: type(x) = 'N' (undesirable result)
>
>Problem is, if there is a variable in scope whose name is the same as the string in x, type() returns the type of that variable....Nasty!
>
>I'm thinking there might be a way to use the TRANSFORM() function to distinguish between the two cases, but I haven't figured it out yet.
"The five senses obstruct or deform the apprehension of reality."
Jorge L. Borges?

"Premature optimization is the root of all evil in programming."
Donald Knuth, repeating C. A. R. Hoare

"To die for a religion is easier than to live it absolutely"
Jorge L. Borges
Previous
Reply
Map
View

Click here to load this message in the networking platform