Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
IsNumeric - VFP analogue?
Message
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
00307922
Message ID:
00307962
Views:
50
>>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.
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform