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

Click here to load this message in the networking platform