Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Problems with Copying/Pasting with [][] characters
#1
Hi Gintaras,

I have a dialog with an edit box which gets populated by with text that has been selected by the user in a richeditfield in another application


Code:
Copy      Help
act child("" SampleAppWindowsFormsRichEdit20W SampleAppHwnd 0x5);err ret
str+ SelectedText = ""
SelectedText.getsel


The user can then edit the text in my QM dialog and then replace the original selected text with a dialog button.

To replace the text back in the original (the problem step), I do the following:


[code](`t)str(`) EditedText.getwintext(`p)((`)(`fq)id(`)(`p)((`)(`n)4(`) hDlg(`p)))(`)

(`t)int(`) SelectedTextIndex (`o)=(`) (`fq)findw(`)(`p)((`)PreEditedReport SelectedText(`p))(`)
(`t)str(`) PostEditedReport (`o)=(`) PreEditedReport
PostEditedReport.findreplace(`p)((`)SelectedText EditedText (`n)4(`) (`s)""(`) SelectedTextIndex(`p))(`)

(`fq)act(`) (`fq)child(`)(`p)((`)reportcid (`s)""(`) SampleAppWindowsFormsRichEdit20W SampleAppHwnd (`n)0x5(`)(`p));(`)(`fq)err(`) (`fq)ret(`)
(`p)'(`)Ca
(`n)0.1(`)
(`fq)outp(`) PostEditedReport(`p)


It works great if the selected text is all within one line (i.e. doesn't have carriage returns like these [][]), but if it is multi-line, the [][]'s cause a failure at the findreplace stage.

e.g.

Original text may look like this:

Quote:This is line 1

This is line 2

and the edited text may look like this

Quote:This is line 1
interspersed text
This is line2

but it gets changed to


Quote:This is line 1[][]interspersed text[][]This is line2

When I made the edit box in my dialog a simple edit box, those [][]'s would appear but if I make it into a rich edit box, they don't appear. If I didn't have to put them back into the text, that would be fine, but since I do, there is problem.

Whether I escape the characters e.g. EditedText.escape(0), or not..it doesn't seem to work. I am not sure at what stage the [][]'s are getting back in and causing the failure of the findreplace....or maybe they do need to be in to do a proper findreplace.
I feel like I am going around in circles....

Any ideas.....?
Thanks!!!
Stuart
#2
does this help
str s = "text 1 [10] text 2"
#3
not sure....the text that is selected in the app can have any line-spacing/paragraph spacing.... so couldn't put that in....(if I understand your suggestion).
Thanks,
Stuart
#4
craig1983 Wrote:does this help
str s = "text 1 [10] text 2"


Yes, on second "hack" at it, that did help.
There was a mix between [] and [10]...I converted all the [10]'s to []'s with a little bit of escaping and de-escaping thrown in. In the end it works...not exactly sure I understand how myself Tongue

thanks for the tip...it got me to the solution!
Stuart


Forum Jump:


Users browsing this thread: 1 Guest(s)