|
意図しない形で変換が行われるのは嫌なのでひと手間掛かりますが
まず置換用のリストを作って、間違っているならそれを変更して
その後に置換実行するようにしてみましょうか
//test.mac
//そのまま起動 :置換リスト作成
//ctrlを押しながら起動 :置換実行
//$n:名前候補
//$b:置換前数字
//$a:置換後名前
if(iskeydown(0x11)){call tikan;}else{call list;}
endmacro;
list:
#x=x;#y=y;#i=0;#j=0;#k=0;begingroupundo;gofiletop;
while (1){
searchdown @"(?<="").*?(?="",)",regular;
if (!result) break;
$n[#i]=gettext(foundtopx,foundtopy,foundendx,foundendy);
#i=#i+1;
}
while(#j<#i){
gofiletop;
searchdown2 @"^""\d+"" .*"+$n[#j]+".*",regular;
golinetop;
searchdown2 @"^""\d+""",regular;
$b[#j]=gettext(foundtopx,foundtopy,foundendx,foundendy);
$a[#j]=$n[#j];
//message $b[#j];
//message $a[#j];
#j=#j+1;
}
$f=filename;
moveto #x,#y;openfile "";
insert $f+"\n";
while(#k<#j){
insert $b[#k]+","+$a[#k]+"\n";
#k=#k+1;
}
replaceallfast @"""","";gofiletop;
saveas "list.txt";
endmacro;
tikan:
if(!basename=="list.txt"){
if(findhidemaru("list.txt")==-1){openfile "list.txt";}
setactivehidemaru findhidemaru("list.txt");}
#i=0;#j=0;gofiletop;beginsel;golineend2;
$f=gettext(seltopx,seltopy,selendx,selendy);
while(1){
searchdown "^\\d+",regular;
if (!result) break;
$b[#i]=gettext(foundtopx,foundtopy,foundendx,foundendy);
#i=#i+1;
}
gofiletop;#i=0;
while(1){
searchdown "(?<=,).*",regular;
if (!result) break;
$a[#i]=gettext(foundtopx,foundtopy,foundendx,foundendy);
#i=#i+1;
}
if(findhidemaru($f)==-1){openfile $f;}
setactivehidemaru findhidemaru($f);begingroupundo;
while(#j<#i){
replaceallfast @"^"""+$b[#j]+@"""",@""""+$a[#j]+@"""",regular;
#j=#j+1;
}
endgroupundo;endmacro;
|
|