Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Numeric string or not?
Message
 
 
To
21/03/2001 20:28:40
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
00487462
Message ID:
00487487
Views:
10
>>Probably i'm missing something, but,
>>if x='1.2' then: type(x)='N'
>>if x='1.a' then: type(x)='U'
>

>
>This almost works but fails in subtle cases.
>
>Suppose:
>
>a123 = 456
>
>if x='123' then: type(x) = 'N'
>if x='a123' then: type(x) = 'N' (undesirable result)
>
>Problem is, if there is a variable in scope whose name is the same as the string in x, type() returns the type of that variable....Nasty!
>
>I'm thinking there might be a way to use the TRANSFORM() function to distinguish between the two cases, but I haven't figured it out yet.
lcMask="0123456789.-"
lcTest1="1.233"
lcTest2="aee12"
lcTest3="-1+5"
lcTest4="1----"
?chrtran(lcTest1,lcMask,replicate(" ",12))
?empty(chrtran(lcTest1,lcMask,replicate(" ",12))) and type(lcTest1)="N"
?empty(chrtran(lcTest2,lcMask,replicate(" ",12))) and type(lcTest2)="N"
?empty(chrtran(lcTest3,lcMask,replicate(" ",12))) and type(lcTest3)="N"
?empty(chrtran(lcTest4,lcMask,replicate(" ",12))) and type(lcTest4)="N"
If it's not broken, fix it until it is.


My Blog
Previous
Reply
Map
View

Click here to load this message in the networking platform