Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Numbers in character field?
Message
 
General information
Forum:
Visual FoxPro
Category:
FoxPro 2.x
Miscellaneous
Thread ID:
00448788
Message ID:
00448900
Views:
7
>It's Larry Miller's sugestion not mine
Sorry Sergey, and Larry! (it's still a cool solution)
>
>Sergey, I've normally done the same as you: Converting the string to a val and back to a string then checking for equality (w/ original string), since isdigit only compares the leftmost char. of string.
>
>I love seeing others solutions, gets me thinking outside my box!

Another one, based on Sergey's idea in other thread:
********************************
function Zip
********************************
lparameters pcZip, pcField
**************************
If empty(pcZip) 
   return .t.
endif
local lnZipLen
lnZipLen=fsize(pcField) && len of the field

local lcMask, lcDigits
lcMask=replicate('9',lnZipLen)
lcDigits = "0123456789"
if  chrtran( pcZip, lcDigits, replicate("9", 10))<>lcMask or pcZip = "00000"
    return EvalCode(179, pcField)
endif

return .t.
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