Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
replacerx and carriage returns
#1
i have a dialog that where im grabbing the clipboard and applying a regex that is built in the dialog. however, sometimes i want to replace some string with a carriage return ([13]) but it actually replaces it with "[13]" rather than the cr. however, it works in a test macro just fine.

can you tell me why it's not working in the dialog?


thanks so much.


Works here
Code:
Copy      Help
_s=
;test~test

_s.replacerx("~" "[13]")
out _s


Doesnt work here.

Code:
Copy      Help
;\Dialog_Editor
;Version 08/03/2006

function# hDlg message wParam lParam
if(hDlg) goto messages
str controls = "5 6 9 10 12 11 13"
str e5 e6 c9Cas c10Who c12Rep c11Mul c13Use a b c d e
int u v w x y z
c13Use = 1
if(!ShowDialog("Live_Search_and_Replace" &Live_Search_and_Replace &controls)) ret
;*******
;BEGIN DIALOG
;0 "" 0x10C80A44 0x100 0 0 191 113 "Search and Replace"
;5 Edit 0x54430080 0x40204 0 16 186 16 ""
;8 Button 0x54022000 0x4 108 1 78 14 "Regular Expressions"
;6 Edit 0x54430080 0x100204 0 44 186 16 ""
;3 Static 0x54000000 0x4 2 5 48 10 "Search For"
;4 Static 0x54000000 0x4 2 34 48 10 "Replace With"
;7 Button 0x54032000 0x4 134 70 48 32 "&Run"
;9 Button 0x54012003 0x0 2 80 66 13 "&Case Sensetive"
;10 Button 0x54012003 0x0 70 80 56 13 "&Whole Word"
;12 Button 0x54012003 0x0 2 96 66 13 "&Replace Once"
;11 Button 0x54012003 0x0 70 96 56 13 "Multiline"
;13 Button 0x54012003 0x0 2 62 96 12 "Use Regular &Expressions"
;14 Static 0x54000010 0x20000 0 76 126 2 ""
;END DIALOG
;DIALOG EDITOR: "" 0x2020105 "" "" ""


ret
;messages
sel message
,case WM_INITDIALOG DT_Init(hDlg lParam);ret 1
,case WM_DESTROY DT_DeleteData(hDlg)
,case WM_COMMAND goto messages2
ret
;messages2
sel wParam
,case 7
,ClearOutput
,v=1
,b.getwintext(id(5 "Search and Replace"))
,c.getwintext(id(6 "Search and Replace"))
,u=but(13 "Search and Replace")
,w=but(12 "Search and Replace")
,x=but(9 "Search and Replace")
,y=but(10 "Search and Replace")
,z=but(11 "Search and Replace")
,if x=1
,,v=0
,if y=1
,,v=v+2
,if z=1
,,v=v+8
,if w=1
,,v=v+4
,a.getclip
,if u=0
,,a.findreplace(b c)
,else
,,out "c=%s" c
,,out "b=%s" b
,,out "v=%i" v
,,a.replacerx(b c v)
,a.setclip    
,clo
,case 8 RegExpMenu id(5 hDlg)    
,;case 13
,,;e6.getwintext(id(6 hDlg))
,,;e6.from(e6 "[]")
,,;e6.setwintext(id(6 hDlg))
,,;d=1
,,;SetFocus (id(6 hDlg))
,,;'E

,case IDCANCEL DT_Cancel hDlg
ret 1
An old blog on QM coding and automation.

The Macro Hook
#2
Escape sequences can be used only in code, not in text that macro gets from somewhere else. Unless you use str.escape.

Macro
Code:
Copy      Help
str s
inp- s "Type text with QM escape sequences"
out "------"
out s
out "------"
s.escape(0)
out s
#3
man, that rabbit hole really goes deep!.....

THANKS!!!!
An old blog on QM coding and automation.

The Macro Hook


Forum Jump:


Users browsing this thread: 1 Guest(s)