Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Numeric string or not?
Message
 
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
00487462
Message ID:
00488154
Views:
13
>>>>Thanks to all for your clever responses. I like Barbara's solution for simplicity, and it should work for the simple cases I'll be looking at.
>>>
>>>Well, my solution:
>>>
>>>?empty(chrtran(lcTest4,"0123456789.-",replicate(" ",12))) and type(lcTest4)="N"
>>>would work for all cases, not only for simple.
>>Nadya,
>>
>>It will fail for following cases
>>
lcTest4 = "1-2-3-4"
>>lcTest4 = "1.2.3.4"
>>
or any combinations of above
>Actually, the second returns .f., which it should.
>But the first one returns .t., which doesn't satisfy. Good catch!
>Thanks.
>We can add one additional if:
>at("-",lcTest4)<2 (could be 0 or 1)

It's not enough.
lcTest4 = "-1-2-3-4" will satisfy that check.
at("-",lcTest4)<2 AND Occurs("-", lcTest4) < 2
should do.
--sb--
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform