Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Numbers in character field?
Message
 
 
Information générale
Forum:
Visual FoxPro
Catégorie:
FoxPro 2.x
Divers
Thread ID:
00448788
Message ID:
00448900
Vues:
15
>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
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform