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!

Removing a character from an alpha field 1

Status
Not open for further replies.

woodyinoz

IS-IT--Management
Jan 8, 2002
215
GB
Hi all,

I have an alpha field which has the following characters in it 

I want to run some script upon the field to remove all of these characters and replace them with a space.
For example:

Field values are 165TBOOM
TESTREALHELP

I them changed to 165T BOOM
TEST REAL HELP

Any ideas how I can do this?

Thanks,

Woody

 
You either need to test for all characters you want in, and delete everything else, or test for all characters you don't want in and delete them.

No magic way of knowing what those characters are, except likely lower than chr(13) and higher than chr(152) (I think the upper end is correct).

Tony McGuire
"It's not about having enough time. It's about priorities.
 
A bit more:

Do you know what those characters are? Are they all the same, or do you have a bunch of different characters?

If there are a limited number of characters you need to strip, I'd probably use breakapart()

var
arBreak array[] string
endvar

breakapart(tc."fieldname",arBreak,chr(183)+chr(158)+chr(32))

This gets you an array with everything EXCEPT chr(183) and chr(158) and 'space' (chr(32).

Then you can simply put the field back together.
Code:
tc.open("tablename.db")
tc.edit()
scan tc :
  tc."fieldname"=arBreak[1]
  for x from 2 to arBreak.size()
    if arBreak[x].size()>0 then
      tc."fieldname"=tc."fieldname"+" "+arBreak[x]
    endif
  endfor
  tc.unlockrecord() ; you should trap for errors here
endscan
tc.endedit()
tc.close()




Tony McGuire
"It's not about having enough time. It's about priorities.
 
OOPS!

The breakapart should appear first within the scan!

And, of course, should reflect the characters you want/need to strip rather than the ones I used.

Tony McGuire
"It's not about having enough time. It's about priorities.
 
Unfortunately I can't replicate the  character in my objectPal code. It seems that the  represents a new line in a memo field which I have now made alpha.
I really need to get rid of the  so that I can output the table into a csv file.

Currently, if I export the table with the  in any field it starts a new line!

Thanks,

Woody
 
All the same character, then?

Try breakapart(tc."fieldname",arBreak,chr(13)+chr(10)+chr(12))

in the code I posted.

You could also do a character by character analysis of the data in that field to come up with exactly what character it is.

Tony McGuire
"It's not about having enough time. It's about priorities.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top