Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Need algorithm for cleaning check numbers
Message
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
00359011
Message ID:
00359017
Views:
14
>Hi All,
>
>I need a quick and elegant (quick's better) to clean up a char field that must contain only numbers.
>
>I have to process some tables that are downloaded from several check cashing stores. Check cashing employees are among the most creative types I've ever come accross.
>
>The app they're using on their end allows them to enter anything in the check number field, so sometimes we end up with "0000243" or "0234r;23".
>
>What I need to do is go through the table and spot anything that has leading zeros or characters as part of the string, so that the two samples above would become "243" and "23423", respectively.
>
>I've created a few different algorithms, but would like to get some ideas from others.
>
>So far the fastest I've found is to go through the whole table and check every record with:
>
>if str( val( checknum)) <> checknum
> *something's not kosher with this number
>endif
>
>If anyone has a more creative approach, please let me know...
>
>Thanks!
>
>Alex


REPLACE ALL checknum WITH CHRTRAN(LOWER(ALLTRIM((checknum)),"abcdefghijklmnopqrstuvwxyz`~!@#$%^&*()-_=+[]{}\|';:/?.,<>"+CHR(34),"")


The CHR(34) will replace any " (quotes) in the string, too.
Fred
Microsoft Visual FoxPro MVP

foxcentral.net
Previous
Reply
Map
View

Click here to load this message in the networking platform