Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Unable to match all double byte characters
#1
hello everyone,

I need to use regular expressions to match all double byte characters, use the following code, and output only one result

I expect The results :
文字一
文字二
文字三
文字四

QM not fully support regular expressions? Any suggestions are welcome. Thanks in advance


Macro Macro15
Code:
Copy      Help
_s=
;DocumentModel document = new DocumentModel();
;
;Section section = new Section(document);
;document.Sections.Add(section);
;
;Paragraph paragraph = new Paragraph(document);
;section.Blocks.Add(paragraph);
;
;Run 文字一run = new Run(document, "文字二");
;paragraph.Inlines.Add(run);
;
;文字三document.Save("test.docx");文字四
;
;//文字
;ComponentInfo.SetLicense("FREE-LIMITED-KEY");

str pattern="(?<!//)[\x80-\xff]+"

int i; ARRAY(str) a
if(findrx(_s pattern 0 0 a)<0) out "does not match"; ret
for i 0 a.len
,out a[i]
#2
Use flag 4. Then the array has 2 dimensions.
Macro Macro3096
Code:
Copy      Help
if(findrx(_s pattern 0 4 a)<0) out "does not match"; ret
for i 0 a.len
,out a[0 i]
#3
oh, Thanks Gintaras.Thank you for your help

I have another question: How to determine whether an array element exists?

I want to fill 10 EditBox in the dialog box with matched elements, but the number of matched elements may be less than 10,

I want to add a branch statement, for example:
if(a[0 0]) e3 = a[0 0] ; else e3 = ""

I expect The results :
If the element exists, it will be displayed in the EditBox. If it does not exist, the EditBox will be empty 【""】

for example, the following code

Macro Macro14
Code:
Copy      Help
_s=
;DocumentModel document = new DocumentModel();
;
;Section section = new Section(document);
;document.Sections.Add(section);
;
;Paragraph paragraph = new Paragraph(document);
;section.Blocks.Add(paragraph);
;
;Run 文字一run = new Run(document, "文字二");
;paragraph.Inlines.Add(run);
;
;文字三document.Save("test.docx");文字四
;
;//文字
;ComponentInfo.SetLicense("FREE-LIMITED-KEY");

str dd=
;BEGIN DIALOG
;0 "" 0x90C80AC8 0x0 0 0 224 136 "Dialog" "4"
;3 Edit 0x54030080 0x200 8 8 96 12 ""
;4 Edit 0x54030080 0x200 8 28 96 13 ""
;5 Edit 0x54030080 0x200 8 48 96 12 ""
;6 Edit 0x54030080 0x200 8 68 96 13 ""
;7 Edit 0x54030080 0x204 8 88 96 12 ""
;8 Edit 0x54030080 0x204 120 8 96 12 ""
;9 Edit 0x54030080 0x204 120 28 96 13 ""
;10 Edit 0x54030080 0x204 120 48 96 12 ""
;11 Edit 0x54030080 0x204 120 68 96 13 ""
;12 Edit 0x54030080 0x204 120 88 96 12 ""
;1 Button 0x54030001 0x4 116 116 48 14 "OK"
;2 Button 0x54030000 0x4 168 116 48 14 "Cancel"
;END DIALOG
;DIALOG EDITOR: "" 0x2040A00 "*" "" "" ""

str controls = "3 4 5 6 7 8 9 10 11 12"
str e3 e4 e5 e6 e7 e8 e9 e10 e11 e12

ARRAY(str) a
str pattern="[\x80-\xff]+"
if(findrx(_s pattern 0 4 a)<0) out "does not match"; ret

e3 = a[0 0]
e4 = a[0 1]
e5 = a[0 2]
e6 = a[0 3]
e7 = a[0 4]
;e8 = a[0 5]
;e9 = a[0 6]
;e10 = a[0 7]
;e11 = a[0 8]
;e12 = a[0 9]

if(!ShowDialog(dd 0 &controls)) ret
#4
this will do what you need.
Code:
Copy      Help
_s=
;DocumentModel document = new DocumentModel();
;
;Section section = new Section(document);
;document.Sections.Add(section);
;
;Paragraph paragraph = new Paragraph(document);
;section.Blocks.Add(paragraph);
;
;Run 文字一run = new Run(document, "文字二");
;paragraph.Inlines.Add(run);
;
;文字三document.Save("test.docx");文字四
;
;//文字
;ComponentInfo.SetLicense("FREE-LIMITED-KEY");

str dd=
;BEGIN DIALOG
;0 "" 0x90C80AC8 0x0 0 0 224 136 "Dialog" "4"
;3 Edit 0x54030080 0x200 8 8 96 12 ""
;4 Edit 0x54030080 0x200 8 28 96 13 ""
;5 Edit 0x54030080 0x200 8 48 96 12 ""
;6 Edit 0x54030080 0x200 8 68 96 13 ""
;7 Edit 0x54030080 0x204 8 88 96 12 ""
;8 Edit 0x54030080 0x204 120 8 96 12 ""
;9 Edit 0x54030080 0x204 120 28 96 13 ""
;10 Edit 0x54030080 0x204 120 48 96 12 ""
;11 Edit 0x54030080 0x204 120 68 96 13 ""
;12 Edit 0x54030080 0x204 120 88 96 12 ""
;1 Button 0x54030001 0x4 116 116 48 14 "OK"
;2 Button 0x54030000 0x4 168 116 48 14 "Cancel"
;END DIALOG
;DIALOG EDITOR: "" 0x2040A00 "*" "" "" ""

str controls = "3 4 5 6 7 8 9 10 11 12"
str e3 e4 e5 e6 e7 e8 e9 e10 e11 e12

ARRAY(str) a
str pattern="[\x80-\xff]+"
if(findrx(_s pattern 0 4 a)<0) out "does not match"; ret
for int'i 0 a.len
,sel i
,,case 0
,,e3 = a[0 i]
,,case 1
,,e4 = a[0 i]
,,case 2
,,e5 = a[0 i]
,,case 3
,,e6 = a[0 i]
,,case 4
,,e7 = a[0 i]
,,case 5
,,e8 = a[0 i]
,,case 6
,,e9 = a[0 i]
,,case 7
,,e10 = a[0 i]
,,case 8
,,e11 = a[0 i]
,,case 9
,,e12 = a[0 i]


if(!ShowDialog(dd 0 &controls)) ret
#5
@kevin

Thank you for your help, Code works final,

Now, I add the search and replace function at the end of the code. It seems to be a little difficult to use the SLE statement
I want to replace the original string with the string entered into the editbox


Macro Macro16
Code:
Copy      Help
_s=
;DocumentModel document = new DocumentModel();
;
;Section section = new Section(document);
;document.Sections.Add(section);
;
;Paragraph paragraph = new Paragraph(document);
;section.Blocks.Add(paragraph);
;
;Run 文字一run = new Run(document, "文字二");
;paragraph.Inlines.Add(run);
;
;文字三document.Save("test.docx");文字四
;
;//文字
;ComponentInfo.SetLicense("FREE-LIMITED-KEY");

str dd=
;BEGIN DIALOG
;0 "" 0x90C80AC8 0x0 0 0 224 136 "Dialog" "4"
;3 Edit 0x54030080 0x200 8 8 96 12 ""
;4 Edit 0x54030080 0x200 8 28 96 13 ""
;5 Edit 0x54030080 0x200 8 48 96 12 ""
;6 Edit 0x54030080 0x200 8 68 96 13 ""
;7 Edit 0x54030080 0x204 8 88 96 12 ""
;8 Edit 0x54030080 0x204 120 8 96 12 ""
;9 Edit 0x54030080 0x204 120 28 96 13 ""
;10 Edit 0x54030080 0x204 120 48 96 12 ""
;11 Edit 0x54030080 0x204 120 68 96 13 ""
;12 Edit 0x54030080 0x204 120 88 96 12 ""
;1 Button 0x54030001 0x4 116 116 48 14 "OK"
;2 Button 0x54030000 0x4 168 116 48 14 "Cancel"
;END DIALOG
;DIALOG EDITOR: "" 0x2040A00 "*" "" "" ""

str controls = "3 4 5 6 7 8 9 10 11 12"
str e3 e4 e5 e6 e7 e8 e9 e10 e11 e12

ARRAY(str) a
str pattern="[\x80-\xff]+"
if(findrx(_s pattern 0 4 a)<0) out "does not match"; ret
for int'i 0 a.len
,sel i
,,case 0
,,e3 = a[0 i]
,,case 1
,,e4 = a[0 i]
,,case 2
,,e5 = a[0 i]
,,case 3
,,e6 = a[0 i]
,,case 4
,,e7 = a[0 i]
,,case 5
,,e8 = a[0 i]
,,case 6
,,e9 = a[0 i]
,,case 7
,,e10 = a[0 i]
,,case 8
,,e11 = a[0 i]
,,case 9
,,e12 = a[0 i]

if(!ShowDialog(dd 0 &controls)) ret

_s.findreplace(a[0 0] F"{e3}")
_s.findreplace(a[0 1] F"{e4}")
_s.findreplace(a[0 2] F"{e5}")
_s.findreplace(a[0 3] F"{e6}")
_s.findreplace(a[0 4] F"{e7}")
_s.findreplace(a[0 5] F"{e8}")
_s.findreplace(a[0 6] F"{e9}")
_s.findreplace(a[0 7] F"{e10}")
_s.findreplace(a[0 8] F"{e11}")
_s.findreplace(a[0 9] F"{e12}")

out _s
#6
since the number of elements in the array can vary. you cant just access an element that doesn't exist. It will cause an error. That was the main reason for using sel. you can do the same thing when the dialog closes 
Code:
Copy      Help
_s=
;DocumentModel document = new DocumentModel();
;
;Section section = new Section(document);
;document.Sections.Add(section);
;
;Paragraph paragraph = new Paragraph(document);
;section.Blocks.Add(paragraph);
;
;Run 文字一run = new Run(document, "文字二");
;paragraph.Inlines.Add(run);
;
;文字三document.Save("test.docx");文字四
;
;//文字
;ComponentInfo.SetLicense("FREE-LIMITED-KEY");

str dd=
;BEGIN DIALOG
;0 "" 0x90C80AC8 0x0 0 0 224 136 "Dialog" "4"
;3 Edit 0x54030080 0x200 8 8 96 12 ""
;4 Edit 0x54030080 0x200 8 28 96 13 ""
;5 Edit 0x54030080 0x200 8 48 96 12 ""
;6 Edit 0x54030080 0x200 8 68 96 13 ""
;7 Edit 0x54030080 0x204 8 88 96 12 ""
;8 Edit 0x54030080 0x204 120 8 96 12 ""
;9 Edit 0x54030080 0x204 120 28 96 13 ""
;10 Edit 0x54030080 0x204 120 48 96 12 ""
;11 Edit 0x54030080 0x204 120 68 96 13 ""
;12 Edit 0x54030080 0x204 120 88 96 12 ""
;1 Button 0x54030001 0x4 116 116 48 14 "OK"
;2 Button 0x54030000 0x4 168 116 48 14 "Cancel"
;END DIALOG
;DIALOG EDITOR: "" 0x2040A00 "*" "" "" ""

str controls = "3 4 5 6 7 8 9 10 11 12"
str e3 e4 e5 e6 e7 e8 e9 e10 e11 e12

ARRAY(str) a
str pattern="[\x80-\xff]+"
if(findrx(_s pattern 0 4 a)<0) out "does not match"; ret
for int'i 0 a.len
,sel i
,,case 0
,,e3 = a[0 i]
,,case 1
,,e4 = a[0 i]
,,case 2
,,e5 = a[0 i]
,,case 3
,,e6 = a[0 i]
,,case 4
,,e7 = a[0 i]
,,case 5
,,e8 = a[0 i]
,,case 6
,,e9 = a[0 i]
,,case 7
,,e10 = a[0 i]
,,case 8
,,e11 = a[0 i]
,,case 9
,,e12 = a[0 i]

if(!ShowDialog(dd 0 &controls)) ret
i=0
for i 0 a.len
,sel i
,,case 0
,,_s.findreplace(a[0 i] F"{e3}")
,,case 1
,,_s.findreplace(a[0 i] F"{e4}")
,,case 2
,,_s.findreplace(a[0 i] F"{e5}")
,,case 3
,,_s.findreplace(a[0 i] F"{e6}")
,,case 4
,,_s.findreplace(a[0 i] F"{e7}")
,,case 5
,,_s.findreplace(a[0 i] F"{e8}")
,,case 6
,,_s.findreplace(a[0 i] F"{e9}")
,,case 7
,,_s.findreplace(a[0 i] F"{e10}")
,,case 8
,,_s.findreplace(a[0 i] F"{e11}")
,,case 9
,,_s.findreplace(a[0 i] F"{e12}")
out _s
#7
How to prevent repeated replacement?

In some cases, the result of the replacement is incorrect

[Image: GIF-2021-01-03-12-00-36.gif]

When some strings repeat, this replacement method is not reliable. Is there a better solution?
#8
@kevin

How to delete the line starting with // From multiple lines of text?

for example:

Macro Macro19
Trigger A6     Help - how to add the trigger to the macro
Code:
Copy      Help
_s=
;DocumentModel document = new DocumentModel();
;
;Section section = new Section(document);
;document.Sections.Add(section);
;
;Paragraph paragraph = new Paragraph(document);
;section.Blocks.Add(paragraph);
;
;Run 文字一run = new Run(document, "文字二");
;paragraph.Inlines.Add(run);
;
;文字三document.Save("test.docx");文字四
;
;//文字
;ComponentInfo.SetLicense("FREE-LIMITED-KEY");

;delete the line starting with //


out _s
#9
I can delete the comment line with the following code, but it will produce an empty line

Macro Macro20
Code:
Copy      Help
_s=
;DocumentModel document = new DocumentModel();
;
;Section section = new Section(document);
;document.Sections.Add(section);
;
;Paragraph paragraph = new Paragraph(document);
;section.Blocks.Add(paragraph);
;
;Run 文字一run = new Run(document, "文字二");
;paragraph.Inlines.Add(run);
;
;文字三document.Save("test.docx");文字四
;
;//文字
;ComponentInfo.SetLicense("FREE-LIMITED-KEY");

_s.replacerx("//.*" "")


out _s

Perfect solution to the problem Smile
_s.replacerx("//.*\n" "")
#10
Use this for your replacement code fixes(In some cases, the result of the replacement is incorrect)Your original code was starting the search every time at the beginning of the string. this will prevent that.
Code:
Copy      Help
int ci
for i 0 a.len
,sel i
,,case 0
,,ci=_s.findreplace(a[0 i] F"{e3}")
,,case 1
,,ci=_s.findreplace(a[0 i] F"{e4}" 4 "" ci+e3.len)
,,case 2
,,ci=_s.findreplace(a[0 i] F"{e5}" 4 "" ci+e4.len)
,,case 3
,,ci=_s.findreplace(a[0 i] F"{e6}" 4 "" ci+e5.len)
,,case 4
,,ci=_s.findreplace(a[0 i] F"{e7}" 4 "" ci+e6.len)
,,case 5
,,ci=_s.findreplace(a[0 i] F"{e8}" 4 "" ci+e7.len)
,,case 6
,,ci=_s.findreplace(a[0 i] F"{e9}" 4 "" ci+e8.len)
,,case 7
,,ci=_s.findreplace(a[0 i] F"{e10}" 4 "" ci+e9.len)
,,case 8
,,ci=_s.findreplace(a[0 i] F"{e11}" 4 "" ci+e10.len)
,,case 9
,,ci=_s.findreplace(a[0 i] F"{e12}" 4 "" ci+e11.len)
#11
@kevin
Thank you very much. The code works very well
#12
@kevin

Because sometimes I need to output the original string, I add a button to implement it

But the following code doesn't work. What should I do? Thanks in advance

Macro Macro9
Code:
Copy      Help
_s=
;DocumentModel document = new DocumentModel();
;
;Section section = new Section(document);
;document.Sections.Add(section);
;
;Paragraph paragraph = new Paragraph(document);
;section.Blocks.Add(paragraph);
;
;Run 文字一run = new Run(document, "文字二");
;paragraph.Inlines.Add(run);
;
;文字三document.Save("test.docx");文字四
;
;//文字
;ComponentInfo.SetLicense("FREE-LIMITED-KEY");

str dd=
;BEGIN DIALOG
;0 "" 0x90C80AC8 0x0 0 0 224 136 "Dialog" "4"
;3 Edit 0x54030080 0x200 8 8 96 12 ""
;4 Edit 0x54030080 0x200 8 28 96 13 ""
;5 Edit 0x54030080 0x200 8 48 96 12 ""
;6 Edit 0x54030080 0x200 8 68 96 13 ""
;7 Edit 0x54030080 0x200 8 88 96 12 ""
;8 Edit 0x54030080 0x200 120 8 96 12 ""
;9 Edit 0x54030080 0x200 120 28 96 13 ""
;10 Edit 0x54030080 0x200 120 48 96 12 ""
;11 Edit 0x54030080 0x200 120 68 96 13 ""
;12 Edit 0x54030080 0x200 120 88 96 12 ""
;13 Button 0x54030001 0x4 64 116 48 14 "Original"
;1 Button 0x54030001 0x4 116 116 48 14 "OK"
;2 Button 0x54030000 0x4 168 116 48 14 "Cancel"
;END DIALOG
;DIALOG EDITOR: "" 0x2040A00 "*" "" "" ""

str controls = "3 4 5 6 7 8 9 10 11 12"
str e3 e4 e5 e6 e7 e8 e9 e10 e11 e12
if(!ShowDialog(dd &sub.DlgProc &controls)) ret

str ss = _s ;;Original string

_s.replacerx("\s*//.*" "") ;;Processed string

#sub DlgProc
function# hDlg message wParam lParam

sel message
,case WM_INITDIALOG
,case WM_DESTROY
,case WM_COMMAND goto messages2

ret
;messages2
sel wParam
,case 13
,out ss ;;out Original string
,case IDOK
,out _s ;;out Processed string
,case IDCANCEL
ret 1
#13
use a thread Variable
change _s to
str- s
Code:
Copy      Help
str- s=
;DocumentModel document = new DocumentModel();
;
;Section section = new Section(document);
;document.Sections.Add(section);
;
;Paragraph paragraph = new Paragraph(document);
;section.Blocks.Add(paragraph);
;
;Run 文字一run = new Run(document, "文字二");
;paragraph.Inlines.Add(run);
;
;文字三document.Save("test.docx");文字四
;
;//文字
;ComponentInfo.SetLicense("FREE-LIMITED-KEY");

str dd=
;BEGIN DIALOG
;0 "" 0x90C80AC8 0x0 0 0 224 136 "Dialog" "4"
;3 Edit 0x54030080 0x200 8 8 96 12 ""
;4 Edit 0x54030080 0x200 8 28 96 13 ""
;5 Edit 0x54030080 0x200 8 48 96 12 ""
;6 Edit 0x54030080 0x200 8 68 96 13 ""
;7 Edit 0x54030080 0x200 8 88 96 12 ""
;8 Edit 0x54030080 0x200 120 8 96 12 ""
;9 Edit 0x54030080 0x200 120 28 96 13 ""
;10 Edit 0x54030080 0x200 120 48 96 12 ""
;11 Edit 0x54030080 0x200 120 68 96 13 ""
;12 Edit 0x54030080 0x200 120 88 96 12 ""
;13 Button 0x54030001 0x4 64 116 48 14 "Original"
;1 Button 0x54030001 0x4 116 116 48 14 "OK"
;2 Button 0x54030000 0x4 168 116 48 14 "Cancel"
;END DIALOG
;DIALOG EDITOR: "" 0x2040A00 "*" "" "" ""

str controls = "3 4 5 6 7 8 9 10 11 12"
str e3 e4 e5 e6 e7 e8 e9 e10 e11 e12
if(!ShowDialog(dd &sub.DlgProc &controls)) ret


#sub DlgProc
function# hDlg message wParam lParam

sel message
,case WM_INITDIALOG
,str- s
,case WM_DESTROY
,case WM_COMMAND goto messages2

ret
;messages2
sel wParam
,case 13
,out s ;;out Original string
,case IDOK
,case IDCANCEL
ret 1
#14
Skillfully deflected Smile   thanks a lot
#15
@kevin

Why can't  paste it

Macro Macro15
Trigger A5     Help - how to add the trigger to the macro
Code:
Copy      Help
str- s=
;DocumentModel document = new DocumentModel();
;
;Section section = new Section(document);
;document.Sections.Add(section);
;
;Paragraph paragraph = new Paragraph(document);
;section.Blocks.Add(paragraph);
;
;Run run = new Run(document, "文字二");
;paragraph.Inlines.Add(run);
;
;document.Save("文字三");
;
;//文字
;ComponentInfo.SetLicense("FREE-LIMITED-KEY");

str dd=
;BEGIN DIALOG
;0 "" 0x90C80AC8 0x0 0 0 224 136 "Dialog" "4"
;3 Edit 0x54030080 0x200 8 8 96 12 ""
;4 Edit 0x54030080 0x200 8 28 96 13 ""
;5 Edit 0x54030080 0x200 8 48 96 12 ""
;6 Edit 0x54030080 0x200 8 68 96 13 ""
;7 Edit 0x54030080 0x200 8 88 96 12 ""
;8 Edit 0x54030080 0x200 120 8 96 12 ""
;9 Edit 0x54030080 0x200 120 28 96 13 ""
;10 Edit 0x54030080 0x200 120 48 96 12 ""
;11 Edit 0x54030080 0x200 120 68 96 13 ""
;12 Edit 0x54030080 0x200 120 88 96 12 ""
;13 Button 0x54030001 0x4 64 116 48 14 "Original"
;1 Button 0x54030001 0x4 116 116 48 14 "OK"
;2 Button 0x54030000 0x4 168 116 48 14 "Cancel"
;END DIALOG
;DIALOG EDITOR: "" 0x2040A00 "*" "" "" ""

str controls = "3 4 5 6 7 8 9 10 11 12"
str e3 e4 e5 e6 e7 e8 e9 e10 e11 e12

_s = s
_s.replacerx("\s*//.*" "")

if(!ShowDialog(dd &sub.DlgProc &controls)) ret

paste _s

#sub DlgProc
function# hDlg message wParam lParam

sel message
,case WM_INITDIALOG
,str- s
,case WM_DESTROY
,case WM_COMMAND goto messages2

ret
;messages2
sel wParam
,case 13
,out s ;;success
,paste s ;;fail
,DT_Cancel(hDlg)
,case IDOK
,case IDCANCEL 
ret 1
#16
where are you trying to paste it to?
#17
The insertion point in the document
#18
When you click the dialog button the focus is now on that button. The Insertion Point doesn't exist anymore. Need to activate the document before using paste.
#19
It's a bit strange. I'm in the insertion point status of the document, and I still can't paste it
#20
please show a video of the problem
#21
https://www64.zippyshare.com/v/BTux2XAV/file.html
#22
Thank you .It is what I thought the issue was.
need to activate  notepad window first.


change code to this
 
Code:
Copy      Help
,case 13
,out s ;;success
,int w=win("" "Notepad")
,int c=id(15 w) ;;editable text 'Text Editor
,act c
,paste s
,DT_Cancel(hDlg)
#23
The input window is uncertain
why?

[Image: pic.png]

paste _s  

It is valid in all windows with input points
#24
Paste Fails while the dialog is open because the dialog is the active window. But once the dialog closes , notepad is the active window again so paste works.

the variable makes no difference. It's because notepad is not the active window. Yes paste needs an active window. Need to get the handle of notepad and make sure it is the active window before using paste.

You could use other commands such as setwintext  which can set text to a background window. also can use setsel

once you click the button on the dialog window even the dialog control loses focus and has no caret. Because the focus has been moved to the button.
#25
I removed the button【Original】 and now 【paste s】 works, but there's no way to cancel


Macro Macro15
Trigger A5     Help - how to add the trigger to the macro
Code:
Copy      Help
str- s=
;DocumentModel document = new DocumentModel();
;
;Section section = new Section(document);
;document.Sections.Add(section);
;
;Paragraph paragraph = new Paragraph(document);
;section.Blocks.Add(paragraph);
;
;Run run = new Run(document, "文字二");
;paragraph.Inlines.Add(run);
;
;document.Save("文字三");
;
;//文字
;ComponentInfo.SetLicense("FREE-LIMITED-KEY");

str dd=
;BEGIN DIALOG
;0 "" 0x90C80AC8 0x0 0 0 224 136 "Dialog" "4"
;3 Edit 0x54030080 0x200 8 8 96 12 ""
;4 Edit 0x54030080 0x200 8 28 96 13 ""
;5 Edit 0x54030080 0x200 8 48 96 12 ""
;6 Edit 0x54030080 0x200 8 68 96 13 ""
;7 Edit 0x54030080 0x200 8 88 96 12 ""
;8 Edit 0x54030080 0x200 120 8 96 12 ""
;9 Edit 0x54030080 0x200 120 28 96 13 ""
;10 Edit 0x54030080 0x200 120 48 96 12 ""
;11 Edit 0x54030080 0x200 120 68 96 13 ""
;12 Edit 0x54030080 0x200 120 88 96 12 ""
;1 Button 0x54030001 0x4 116 116 48 14 "OK"
;2 Button 0x54030000 0x4 168 116 48 14 "Cancel"
;END DIALOG
;DIALOG EDITOR: "" 0x2040A00 "*" "" "" ""

str controls = "3 4 5 6 7 8 9 10 11 12"
str e3 e4 e5 e6 e7 e8 e9 e10 e11 e12

_s = s
_s.replacerx("\s*//.*" "")

;if(!ShowDialog(dd &sub.DlgProc &controls)) ret
if(!ShowDialog(dd &sub.DlgProc &controls)) paste s; ret

paste _s

#sub DlgProc
function# hDlg message wParam lParam

sel message
,case WM_INITDIALOG
,str- s
,case WM_DESTROY
,case WM_COMMAND goto messages2

ret
;messages2
sel wParam
,case IDOK
,case IDCANCEL 
ret 1
#26
another way using setsel
 
Code:
Copy      Help
,case 13
,out s ;;success
,int w=win("" "Notepad2")
,int c=id(64259 w) ;;Scintilla
,s.setsel(0 c)
,DT_Cancel(hDlg)

or
Code:
Copy      Help
,case 13
,out s ;;success
,int w=win("" "Notepad2")
,act w
,paste s
,DT_Cancel(hDlg)
#27
I need to paste it in multiple software windows Sad
#28
this should work for you. Gets handle of active window when ctrl+F5 is pressed
and stores it for use later when button is clicked.
So just need to make sure  the correct window is active before pressing ctrl+F5.

Function DialogTester
Trigger AF5     Help - how to add the trigger to the macro
Code:
Copy      Help
int- windowHandle=win()
str- s=
;DocumentModel document = new DocumentModel();
;
;Section section = new Section(document);
;document.Sections.Add(section);
;
;Paragraph paragraph = new Paragraph(document);
;section.Blocks.Add(paragraph);
;
;Run run = new Run(document, "文字二");
;paragraph.Inlines.Add(run);
;
;document.Save("文字三");
;
;//文字
;ComponentInfo.SetLicense("FREE-LIMITED-KEY");

str dd=
;BEGIN DIALOG
;0 "" 0x90C80AC8 0x0 0 0 224 136 "Dialog" "4"
;3 Edit 0x54030080 0x200 8 8 96 12 ""
;4 Edit 0x54030080 0x200 8 28 96 13 ""
;5 Edit 0x54030080 0x200 8 48 96 12 ""
;6 Edit 0x54030080 0x200 8 68 96 13 ""
;7 Edit 0x54030080 0x200 8 88 96 12 ""
;8 Edit 0x54030080 0x200 120 8 96 12 ""
;9 Edit 0x54030080 0x200 120 28 96 13 ""
;10 Edit 0x54030080 0x200 120 48 96 12 ""
;11 Edit 0x54030080 0x200 120 68 96 13 ""
;12 Edit 0x54030080 0x200 120 88 96 12 ""
;13 Button 0x54030001 0x4 64 116 48 14 "Original"
;1 Button 0x54030001 0x4 116 116 48 14 "OK"
;2 Button 0x54030000 0x4 168 116 48 14 "Cancel"
;END DIALOG
;DIALOG EDITOR: "" 0x2040A00 "*" "" "" ""

str controls = "3 4 5 6 7 8 9 10 11 12"
str e3 e4 e5 e6 e7 e8 e9 e10 e11 e12

_s = s
_s.replacerx("\s*//.*" "")

if(!ShowDialog(dd &sub.DlgProc &controls)) ret

paste _s

#sub DlgProc
function# hDlg message wParam lParam

sel message
,case WM_INITDIALOG
,str- s
,int- windowHandle
,case WM_DESTROY
,case WM_COMMAND goto messages2

ret
;messages2
sel wParam
,case 13
,out s ;;success
,act windowHandle
,paste s
,DT_Cancel(hDlg)
,case IDOK
,case IDCANCEL
ret 1
#29
Good idea. Code works well

@kevin
Using #10 code, there are still replacement errors, which seems a little difficult


[Image: abc.gif]

Macro Macro9
Trigger A5     Help - how to add the trigger to the macro
Code:
Copy      Help
_s=
;class Program
;{
;,static void Main()
;,{
;,,ComponentInfo.SetLicense("FREE-LIMITED-KEY");
;
;,,DocumentModel document = new DocumentModel();
;
;,,Section section = new Section(document);
;,,document.Sections.Add(section);
;
;,,Paragraph paragraph = new Paragraph(文件);
;,,section.Blocks.Add(paragraph);
;
;,,Run run = new Run(document, "文字");
;,,paragraph.Inlines.Add(run);
;
;,,document.Save("文件名.docx");
;,}
;}

str dd=
;BEGIN DIALOG
;0 "" 0x90C80AC8 0x0 0 0 224 136 "Dialog" "4"
;3 Edit 0x54030080 0x200 8 8 96 12 ""
;4 Edit 0x54030080 0x200 8 28 96 13 ""
;5 Edit 0x54030080 0x200 8 48 96 12 ""
;6 Edit 0x54030080 0x200 8 68 96 13 ""
;7 Edit 0x54030080 0x200 8 88 96 12 ""
;8 Edit 0x54030080 0x200 120 8 96 12 ""
;9 Edit 0x54030080 0x200 120 28 96 13 ""
;10 Edit 0x54030080 0x200 120 48 96 12 ""
;11 Edit 0x54030080 0x200 120 68 96 13 ""
;12 Edit 0x54030080 0x200 120 88 96 12 ""
;1 Button 0x54030001 0x4 116 116 48 14 "OK"
;2 Button 0x54030000 0x4 168 116 48 14 "Cancel"
;END DIALOG
;DIALOG EDITOR: "" 0x2040A00 "*" "" "" ""

str controls = "3 4 5 6 7 8 9 10 11 12"
str e3 e4 e5 e6 e7 e8 e9 e10 e11 e12

ARRAY(str) a
str pattern="[\x80-\xff]+" ;;Match all double byte characters
if(findrx(_s pattern 0 4 a)<0) out "does not match"; ret
for int'i 0 a.len
,sel i
,,case 0
,,e3 = a[0 i]
,,case 1
,,e4 = a[0 i]
,,case 2
,,e5 = a[0 i]
,,case 3
,,e6 = a[0 i]
,,case 4
,,e7 = a[0 i]
,,case 5
,,e8 = a[0 i]
,,case 6
,,e9 = a[0 i]
,,case 7
,,e10 = a[0 i]
,,case 8
,,e11 = a[0 i]
,,case 9
,,e12 = a[0 i]

if(!ShowDialog(dd 0 &controls)) ret

int ci
for i 0 a.len
,sel i
,,case 0
,,ci=_s.findreplace(a[0 i] F"{e3}")
,,case 1
,,ci=_s.findreplace(a[0 i] F"{e4}" 4 "" ci+e3.len)
,,case 2
,,ci=_s.findreplace(a[0 i] F"{e5}" 4 "" ci+e4.len)
,,case 3
,,ci=_s.findreplace(a[0 i] F"{e6}" 4 "" ci+e5.len)
,,case 4
,,ci=_s.findreplace(a[0 i] F"{e7}" 4 "" ci+e6.len)
,,case 5
,,ci=_s.findreplace(a[0 i] F"{e8}" 4 "" ci+e7.len)
,,case 6
,,ci=_s.findreplace(a[0 i] F"{e9}" 4 "" ci+e8.len)
,,case 7
,,ci=_s.findreplace(a[0 i] F"{e10}" 4 "" ci+e9.len)
,,case 8
,,ci=_s.findreplace(a[0 i] F"{e11}" 4 "" ci+e10.len)
,,case 9
,,ci=_s.findreplace(a[0 i] F"{e12}" 4 "" ci+e11.len)

paste _s
#30
easy fix change
Code:
Copy      Help
,,case 0
,,ci=_s.findreplace(a[0 i] F"{e3}")
to
Code:
Copy      Help
,,case 0
,,ci=_s.findreplace(a[0 i] F"{e3}" 4)


Forum Jump:


Users browsing this thread: 1 Guest(s)