Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Numeric string or not?
Message
 
À
21/03/2001 20:28:40
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Divers
Thread ID:
00487462
Message ID:
00488083
Vues:
10
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
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform