Normal Topic @GetSelectionContents() issues question (Read 872 times)
BOBSCOTT
Senior Member
Members
*****
Offline


That Darn Computer #$X#
{curse words}

Posts: 1195
Joined: Nov 22nd, 2002
@GetSelectionContents() issues question
May 19th, 2012 at 4:30pm
Print Post Print Post  
I have a routine that parses data from a screen scrape. The way I had it working was  the user pasted the copied data to an element named convertbox and pressed the parse command button.

It worked great but was a bit of a kludge.

I tried cleaning it up by eliminating the paste into an element using @GetSelectionContents().

My problem is that windows cut and paste does not have the ^M carriage return  / end of line and @GetSelectionContents()  does.

When I try to change my parse routine and remove the ^M   - I can't. I have tried removing or substituting and then removing  but I cannot seem to manipulate the ^M. I thought  ^M is  @chr(13) and used
str1 = @replace(@GetSelectionContents(), "@chr(13)", "")
And also
writting to the element than manipulating it str1 = @replace(convertbox, "@chr(13)", "")
And also
Replacing it with another letter   str1 = @replace(@GetSelectionContents(), "@chr(13)", X"")
even replacing a ^ and M
And many many others.

I imagine there is a simple method, however it seems to allude me.

Can someone point out the errors of my way? 
Thanks

  

Team – Together Everyone Achieves More
Back to top
 
IP Logged
 
Bharat_Naik
Senior Member
Members
*****
Offline


Ever ready to learn and
share

Posts: 1202
Location: Chicago,  Illinois
Joined: Dec 16th, 2003
Re: @GetSelectionContents() issues question
Reply #1 - May 19th, 2012 at 6:00pm
Print Post Print Post  
Hi Bob,
I have not tried the code using @GetSelectionContents() but many time CR usually is combination of @Chr (13) and @chr (10), that is linefeed. Try to remove both of them and see if that makes any difference.
  
Back to top
 
IP Logged
 
Bharat_Naik
Senior Member
Members
*****
Offline


Ever ready to learn and
share

Posts: 1202
Location: Chicago,  Illinois
Joined: Dec 16th, 2003
Re: @GetSelectionContents() issues question
Reply #2 - May 19th, 2012 at 7:01pm
Print Post Print Post  
Below is the Quote I got it from one of the boards for answer of, How to remove ^M character from text.

Quote:
"Unix uses the line feed, aka LF, with the ascii value of 10. Windows uses the carriage return / line feed combo (two characters). The carriage return, aka CR, has an ascii value of 13. And some systems uses just the CR.

If you want to get rid of the line separators. Get rid of all LFs and CRs, and you'll do it for all systems."
  
Back to top
 
IP Logged
 
Rick_R
Full Member
***
Offline



Posts: 243
Joined: Jan 29th, 2010
Re: @GetSelectionContents() issues question
Reply #3 - May 20th, 2012 at 2:06am
Print Post Print Post  
One problem with simply deleting CR and LF is you might wind up joining the last word of the first line with the first word of the next line. Wordprocessors treat CR/LF as a "soft" return and automatically add or remove a space as necessary.  (If you can get a copy of WordPerfect, type some text, then turn on Reveal Codes and look at what happens to line ends when you change line width or add text to the beginning of a line, thereby changing the end point.)
  
Back to top
 
IP Logged
 
Carl Underwood
Senior Member
Members
*****
Offline



Posts: 1351
Location: New Hampshire
Joined: Mar 11th, 2003
Re: @GetSelectionContents() issues question
Reply #4 - May 20th, 2012 at 2:30am
Print Post Print Post  
The ^M does represent the CR (Carriage Return). The problem is with your replacement statement. You have the @Chr(13) inside quotes, so it is trying to find that literal string, rather than ASCII character 13.

Change this:
str1 = @replace(@GetSelectionContents(), "@chr(13)", "")

To this:
str1 = @replace(@GetSelectionContents(), @chr(13), "")

And it should work for you.


Also, you can use this bit of code to visualize the CRs and LFs:
Code
Select All
var vStr as String

vStr = @GetSelectionContents()

vStr = @Replace(vStr, @Chr(13), "(CR)")
vStr = @Replace(vStr, @Chr(10), "(LF)")

WriteLn(vStr)
 

  


Carl Underwood
CDU Computer Consulting LLC
Epsom, New Hampshire
Back to top
IP Logged
 
BOBSCOTT
Senior Member
Members
*****
Offline


That Darn Computer #$X#
{curse words}

Posts: 1195
Joined: Nov 22nd, 2002
Re: @GetSelectionContents() issues question
Reply #5 - May 20th, 2012 at 4:31am
Print Post Print Post  
Thank you, Thank you, Thank you.

You guys got it solved, thanks for all the input everyone.

I am absolutely sure some people would say I am exaggerating  when they hear me say
"I love you ALL",
However they would be wrong! I truly love all of you.

There is no place else I know where  people are so willing to help. If it's not the developers themselves  doing everything possible to help. Its other users coming to my aid.

You all are the best and I really appreciate the help.
  

Team – Together Everyone Achieves More
Back to top
 
IP Logged