Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
IsNumeric - VFP analogue?
Message
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Divers
Thread ID:
00307922
Message ID:
00307962
Vues:
48
>>George,
>>
>>IsDigit() checks only first symbol, so it's not suitable for my situation. Type() works fine.
>>
>>Example:
>>
>>myNumber='12345'
>>type(myNumber)='N'
>>isDigit(myNumber)=.t.
>>
>>myNumber='1hffhhf'
>>type(myNumber)='U'
>>isdigit(myNumber)=.t.
>
>Nadya,
>
>This behavior is not in accordance with the docs. Whether or not it's a bug, I don't know.

George,

It is not a bug and it is in accordance with the docs. The TYPE() function returns the data type for an expression, any expression.

TYPE("12x12") = N
TYPE(FOUND()) = L
etc.

So when we do;

Var = "12345"
TYPE(var)

we are gfetting teh type of the contents of var which is numeric, the type of the variable named var is character (note the quotes in the assignment line).

Another method that would work is;

STR(VAL(Var),LEN(Var)) = Var

Although some numeric strings would fail the test.

VarType() would not work here because it is the value inside the var that Nadya wants the type for, not the var itself.
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform