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

Non-printable characters in memo field:remove just these

Status
Not open for further replies.

taterday

Programmer
Jan 28, 2009
183
US
Users used word, etc and copied and pasted their information into these memo fields. It resulted in strange characters at random in the data tables.

Are there any way to remove these?
 
try something like this
Code:
PUBLIC cText,cRemove
*text with funny character
cText="abc?¤§def"
?cText

FOR n = 1 TO 31
cremove=CHR(n)
ctext = CHRTRAN(cText,cRemove,"")
ENDFOR

FOR n = 127 TO 255
cremove=CHR(n)
ctext = CHRTRAN(cText,cRemove,"")
ENDFOR


?ctext

There is also a way to do this with regular expressions but they flew right over my head!
wjwjr

This old world keeps spinning round - It's a wonder tall trees ain't layin' down
 
copied into the memo fields... which way did they do that?
What's your form structure or did you simply give them a browse?

memos are text fields, the only real difference to char fields is, the may contain more than 254 chars. No word formatting will be copied.

In principle you should get the same result with memo fields, as you get by copying from word and pasting into notepad.

Without knowing how and what really got into your memos, it's hard to help you. If you did something like insert into table (memofield) (filetostr(word.doc)), then you copied the object code, a word document is, into a text field. It wouldn't help you much, to simply remove any non letters, because there would still remain many text from the parts of the doc file, that don't belong into the visual part of the word documents text. You might recreate the word docs then by strtofile(memofield,"word.doc"), then you're lucky, because only a binary memo field would ensure you get the exact binary data back, that you inserted.

Bye, Olaf.
 
Taterday,

White605 has given you a good solution. An alterntive would be something like:

Code:
lcGoodChars = ;
  "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789!@#$%^&*()_+,./"
lcStr = ;
 CHRTRAN(lcStr, CHRTRAN(lcStr, lcGoodChars, ""), "")

lcGoodChars should contain all the characters that you will allow. This code will remove all characters except the ones you specify. This should be faster than White605's suggestion.

Mike

__________________________________
Mike Lewis (Edinburgh, Scotland)

My Visual FoxPro site: www.ml-consult.co.uk
 
Thank you guys for your help. As everyone knows even if it can not be done a user can do.
I am using a editbox with copy and paste on the right click event. I don't even know what the characters are; they appear as periods, trash, etc when printed.
I think the code above will fix my problem.

Thanks again.

taterday
 
How did you implement the rightclick menu? Did you use system menu items Paste
(_MED_PASTE) or Paste Special (_MED_PSTLK)?

Bye, Olaf.

 
I used the _med_paste. There are the cut, copy, etc available to the users. Works beautiful for the users who do not know the ctrl keys.

bye, taterday
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top