Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Checking string for predefined format
Message
 
 
To
10/08/2000 14:41:51
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
00403485
Message ID:
00403667
Views:
26
>OK, OK, the help says that for Character strings, no transform is performed. :)
>Yup, I see what you mean. I think that has to do with the fact that the lengths of the masks and the lcAPN values are different. But that still sounds like an undocumented feature.
>
>This was part of my test. If the alphas and numerics are switched, they both return .T.
lcAPN = "123456A-B789012C-D345678EF-GH901234I-KLMNOP"
>?(lcApn= TRANSFORM(lcAPN, "999999X-X999999X-X999999XX-XX999999X-XXXXXX"))
>lcAPN = "ABCDEF1-2DEFGHI3-4JKLMNO56-78PQRSTU9-012345"
>?(lcApn= TRANSFORM(lcAPN, "999999X-X999999X-X999999XX-XX999999X-XXXXXX"))
Yep, doesn't work.

I used function, Sergey proposed, with some modifications:
********************************************************************
*  Description.......: ValidateAPN1
*  Calling Samples...: ValidateAPN1(APN)
*  Parameter List....:
*  Created by........:  Sergey Berezniker
*  Modified by.......: Nadya Nosonovsky 08/10/2000 04:47:29 PM
********************************************************************
lparameters pcAPN
local lcMask,  lcDigits, lcLetters, lcAPNUniform

lcMask = "999999X-X999999X-X999999XX-XX999999X"
*lcAPN  = "000000 - 001000 - 000000  -  000000"
lcApn = padr(ltrim(pcAPN),36)
lcDigits = "0123456789"
lcLetters = "ABCDEFGHIJKLMNOPQRSTUVWXYZ "
lcAPNUniform = chrtran( lcAPN, lcDigits+lcLetters, ;
     replicate("9", 10)+ replicate("X", 27))

*wait window lcAPNUniform+' lcMask:'+lcMask+" lcAPN:"+substr(lcAPN,37,1)

return (left(lcAPNUniform,36) = lcMask and inlist(substr(lcAPN,37,1)," ","-"))
I also made time comparision with our original UDF (which I also made more efficient) and this UDF, and Sergey's function ~3 times faster in 1000 loop.


>
>>Strange, but these are my tests:
>>lcAPN = "123456A-B789012C-D345678EF-GH901234I-KLMNOP"
>>?(lcApn= TRANSFORM(lcAPN, "999999X-X999999X-X999999XX-XX999999X-XXXXXX"))
>>lcAPN = "a123456A-B789012C-D345678EF-GH901234I-KLMNOP"
>>?(lcApn= TRANSFORM(lcAPN, "999999X-X999999X-X999999XX-XX999999X-XXXXXX"))
>...
>>
>>Undocumented feature?
If it's not broken, fix it until it is.


My Blog
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform