Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Testing a Character field for Numeric Data'
Message
From
28/07/2009 17:05:50
 
 
To
28/07/2009 16:54:10
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Environment versions
Visual FoxPro:
VFP 9 SP2
OS:
Windows XP SP2
Miscellaneous
Thread ID:
01415119
Message ID:
01415182
Views:
53
>>>>
>>>>x = '0.8'
>>>>? TYPE(x)   &&returns "N"
>>>>? VARTYPE(x)   &&returns "C"
>>>>
>>>
>>>The only thing I would add that has gotten me in the past is to check for 'E' and 'X' containing in the field. 1e9 will say it's a number because e gets defined by foxpro as exponent and 0x90 is considered hex and foxpro evaluates it to a number.
>>
>>Check the thread I pointed Yossi for more thorough discussion on the problem.
>>
>>You can have + - */ etc. (any expression that will evaluate as a number).
>
>I got caught with:
>
>
>x = '9/9/2009'   &Date data not numeric
>? type(x)   &&returns "N"
>
>
>I am working with fields in a table, so for my purposes if there is even one '/' in the field, it's not numeric, so I fixed this by saying:
>
>
>do case
>case AT('/',x) > 0
>    *Do date processing
>case type(x) = 'N'
>    *Do Numeric processing
>otherwise
>    *Do String processing
>Endcase
>
You can check #1415146 I wrote a function but it seemed overkill at the time but maybe it's what you need
Charles

"The code knows no master." - Chuck Mautz
"Everybody is ignorant, only on different subjects." - Will Rogers
Previous
Reply
Map
View

Click here to load this message in the networking platform