Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
line replacement in dialogs
#1
i have a handy little dialog that handles realtime findreplace via the clipboard.
however, when i want to replace a character with a line return (ie "[]") it puts in the actual "[]" characters. i even tried to code in a specific findreplace for that instance but it still just puts in the characters

how can i do this?

Code:
Copy      Help
\Dialog_Editor

function# hDlg message wParam lParam
if(hDlg) goto messages
str controls = "5 6"
str e5 e6 a b c
if(!ShowDialog("S_R_Clipboard" &S_R_Clipboard &controls)) ret

;BEGIN DIALOG
;0 "" 0x10C80A44 0x100 0 0 105 78 "Form"
;5 Edit 0x54030080 0x204 0 14 96 14 ""
;6 Edit 0x54030080 0x204 0 44 96 14 ""
;7 Button 0x54032000 0x0 0 62 48 14 "&Run"
;2 Button 0x54030000 0x4 50 62 48 14 "Cancel"
;3 Static 0x54000001 0x4 0 0 48 12 "Search For"
;4 Static 0x54000001 0x4 0 30 48 13 "Replace With"
;END DIALOG
;DIALOG EDITOR: "" 0x2010800 "" ""


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 IDOK DT_Ok hDlg
,case 7
,,b.getwintext(id(5 "Form"))
,,c.getwintext(id(6 "Form"))
,,a.getclip
,,if c="[]"
,,,a.findreplace(b "[]")
,,else
,,,a.findreplace(b c)
,,a.setclip    
,,clo
,case IDCANCEL DT_Cancel hDlg
ret 1
#2
Two choices:

1. Use multiline edit controls. Then you don't have to use escape sequences like [] or ''. If closing the dialog using Enter is actual, remove ES_WANTRETURN style from edit boxes, and use Ctrl+Enter to add new line.

2. Use str.escape to unescape b and c:
Code:
Copy      Help
,,b.getwintext(id(5 hDlg))
,,c.getwintext(id(6 hDlg))
,,b.escape(0)
,,c.escape(0)
,,a.getclip
,,a.findreplace(b c)
,,a.setclip
#3
thanks!

#2 worked great...#1 kept replacing the char with (null).


Forum Jump:


Users browsing this thread: 1 Guest(s)