Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Getting rid of non-printable junk
Message
Information générale
Forum:
Visual FoxPro
Catégorie:
Autre
Divers
Thread ID:
00241748
Message ID:
00241767
Vues:
18
>Does anyone know a simple command to get rid of all non-printable characters from a field. I have a nomenclature field and the user has been entering some carriage returns, tabs, and control characters (inadvertantly) Is there a way that I can get rid of those characters and leave the alpha numeric printable stuff. I know I can do a loop reading every character and checking for its ascii value, but what I was looking for was a function that can be used in a replace statement. TIA

The easiest thing to do would be to create a string containing all characters you want filtered from the file, and then do the following

* I assume that cFilteredChars contains the list of characters to remove
* and cFld is the field to be stripped
REPLACE ALL cFld WITH CHRTRAN(cFld,cFilteredChars,'')

putting together the list should require a little work; essentially, if only standard printed ASCII characters were acceptable, then you could build cFilteredChars at least in part using:
cFilteredChars = ''
LOCAL i
FOR i = 0 TO 31 && characters below " " are Control characters
   cFilteredChars = cFilteredChars + CHR(i)
ENDFOR
FOR i = 128 TO 255 && high-order bit set is bad
   cFilteredChars = cFilteredChars + CHR(i)
ENDFOR
You could then concatenate any others you want to strip.
EMail: EdR@edrauh.com
"See, the sun is going down..."
"No, the horizon is moving up!"
- Firesign Theater


NT and Win2K FAQ .. cWashington WSH/ADSI/WMI site
MS WSH site ........... WSH FAQ Site
Wrox Press .............. Win32 Scripting Journal
eSolutions Services, LLC

The Surgeon General has determined that prolonged exposure to the Windows Script Host may be addictive to laboratory mice and codemonkeys
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform