Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

FoxPro 2

Status
Not open for further replies.

Phil Thoms

Programmer
Oct 31, 2005
245
GB
I am importing a lot of telephone numbers into a character field, at the end of each telephone number there appears a capital letter which I want to get rid of. As each telenumber is a different length what is the best way of disappearing these letters ?
 

Try this:

Code:
REPLACE tel_num WITH LEFT(tel_num,LEN(ALLTRIM(tel_num))-1) ;
	FOR ISALPHA(RIGHT(ALLTRIM(tel_num),1))
 
If the leftmost letter is always the same you could do this:

REPLACE ALL tel_num WITH ATXLEFT(tel_num, '?') replacing the '?' with the letter in question. (faq184-5975)

If you have only a few different letters you could repeat this for each letter. Otherwise, using something like in the previous post would be best.


mmerlinn

"Political correctness is the BADGE of a COWARD!"

 
If the values of the alpha characters are A-I and "{", then you may be losing data -- it could be that the data was previously stored as numeric in zoned decimal/packed format. Let me know if you need to know how to convert the alpha characters to back to ascii numeric.

~Marsh
 
philthoms,
try
copy to mybackup
* necessary before each repl all !!!
repl all tel_num with alltrim(str(val(tel_num),len(tel_num),0)
Tesar
 

tesar,

If phone numbers have special characters for separation, such as dashes, dots, parenthesis, everything after the first one will be cut off, too.
 
Stella,
you are fully right.
Your solution is better.
I supposed only numbers, ended with first other character.
Only one my positive is first backup,
mainly for missing my last parenthesis...
Thanks.
Tesar
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top