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 IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Removing last character in a character field

Status
Not open for further replies.

drpep

Technical User
Dec 1, 2000
12
US
I imported character data into a character field and received an unfamiliar character at the beginning and end of the data. The data is variable in length. I was able to remove the unfamiliar character at the beginning with SUBSTR. Any method to remove the ending character. Thanks in advance
 
One way:
cData = LEFT(cData,LEN(TRIM(cData))-1)

Or, if its the same character at both ends:
cChr = LEFT(cData,1)
cData = STRTRAN(cData,cChr,'',1,OCCURS(cChr,cData))

Regards,
Jim
 

Yet another way (this is going to run and run):

If you happen to know what the spurious character is (I'll assume it's a binary zero, which is likely to be the case):

cData = ALLTRIM(cData, 1, CHR(0))

(But only works in 9.0)

Mike

__________________________________
Mike Lewis (Edinburgh, Scotland)

My Visual FoxPro site: www.ml-consult.co.uk
 
Thank you for your quick responses. All the solutions worked perfectly. I deeply appreciate your assistance.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top