Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Replace more than one character at a time STRTRAN?
Message
 
 
To
04/05/2004 10:12:56
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
00900695
Message ID:
00900744
Views:
20
Tracy,

chrtran() is "normally" supposed to substitute one character for another.

? chrtran( lcText, "ABC", "DEF" ) && change A to D, B to E and C to F

An empty third argument allows all of the second argument characters to be removed. And I think this is how most calls to chrtran() are used.

If your intput might contain other characters like - or () and you don't want to have to worry about all possible "bad" characers to filter out you can instead us a "good" character list with two chrtran calls:
lcGoodCharacters = "0123456789."
? chrtran( lcText, chrtran( lcText, lcGoodCharacters, "" ), "" )
the inner chrtran() gives out a list of all of the bad characters, that the outer chrtran() then removes from the string.

>Thanks Sergey. I looked up CHRTRAN() in help, but I didn't see where it would replace more than one value. I missed that! I tested the same code using STRTRAN() and mvalue remained the same with no substitutions... That's my memory for ya! Useless! :o)
df (was a 10 time MVP)

df FoxPro website
FoxPro Wiki site online, editable knowledgebase
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform