01-23-2021, 06:11 AM
here you go.
This will display the the original string in the dialog but only do replacements on non commented lines.
This will display the the original string in the dialog but only do replacements on non commented lines.
_s=
;class Program
;{
;,static void Main()
;,{
;,,//文件名 文字 文件
;,,Section section = new Section(document);
;,,document.Sections.Add(section);
;
;,,//This is the comment 文件
;,,Paragraph paragraph = new Paragraph(文件);
;,,section.Blocks.Add(paragraph);
;
;,,Run run = new Run(document, "文字");
;,,paragraph.Inlines.Add(run);
;
;,,document.Save("文件名.docx");
;,}
;}
str s; int i j
ARRAY(int) linenumbers
ARRAY(str) a b
a=_s
for i 0 a.len
,if(findrx(a[i] "//.*")>=0)
,,linenumbers[]=i
for(i a.len-1 -1 -1)
,for j 0 linenumbers.len
,,if(i=linenumbers[j])
,,,a.remove(i)
s=a
s.trim
str dd=
;BEGIN DIALOG
;0 "" 0x90C80AC8 0x0 0 0 334 200 "Dialog" "4"
;3 Edit 0x54030080 0x200 8 160 95 13 ""
;4 Edit 0x54030080 0x200 120 160 95 13 ""
;5 Edit 0x54030080 0x200 232 160 95 13 ""
;6 Edit 0x54231044 0x200 8 8 318 146 ""
;1 Button 0x54030001 0x4 216 180 48 14 "OK"
;2 Button 0x54030000 0x4 272 180 48 14 "Cancel"
;END DIALOG
;DIALOG EDITOR: "" 0x2040B01 "*" "" "" ""
str controls = "3 4 5 6"
str e3 e4 e5 e6
e6=_s;; show original string in edit6
a.redim
str pattern="[\x80-\xff]+" ;;Match all double byte characters
if(findrx(s pattern 0 4 a)<0) out "does not match"; ret
for i 0 a.len
,sel i
,,case 0
,,e3 = a[0 i]
,,case 1
,,e4 = a[0 i]
,,case 2
,,e5 = 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}" 4)
,,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)
b=s
for i 0 b.len
,for j 0 linenumbers.len
,,if(i=linenumbers[j])
,,,str ss.getl(_s linenumbers[j])
,,,b.insert(linenumbers[j])
,,,b[linenumbers[j]]=ss
_s=b
_s.trim
mes _s