|
でがらしさん,
少し手を入れてみました。
//-----------------------------------------------------
$delimiter = "#";
$folder = "C:\\A";
$a = input("検索する文字列を入力して下さい");
if( result == 0 ) endmacro; //キャンセルなら終了
menu "&1 冒頭から最初の区切り線まで",
"&2 区切り線で囲まれた範囲",
"&3 最後の区切り線からファイル末尾まで";
#part = result;
#start = tickcount;
#main = hidemaruhandle(0);
setcompatiblemode 0x003c;
title "実行中・・・";
grep $a, "*.*", $folder, filelist;
if( result == 0 ) {
message "該当なし";
quit;
}
showwindow 0;
replaceallfast "\\([0-9]+\\)", "", regular;
#grephandle = hidemaruhandle(0);
gofiletop;
#i = 1;
while( code != eof ) {
$file[#i] = $folder + "\\" + gettext2( 0, lineno, linelen2, lineno );
#i = #i + 1;
moveto2 0, lineno + 1;
}
#num = #i;//ファイル数
#i = 1;
while( #i < #num ) {
call Sub;
#i = #i + 1;
}
setactivehidemaru #rep;
closehidemaru #object;
closehidemaruforced #grephandle;
clearupdated;
gofiletop;
#time = tickcount - #start;
showwindow 1;
message "検索ファイル数:" + str(#num) + "\n" + str(#time / 1000) + " 秒 "
+ str(#time % 1000);
endmacro;
Sub:
openfile "/h " + $file[#i];
disabledraw;
closehidemaru #object;
#object = hidemaruhandle(0);
if( #part == 1 ) {
gofiletop;
beginsel;
searchdown "^" + $delimiter, regular;
if( !result ) {
escape;
return;
}
} else if( #part == 2 ) {
gofiletop;
searchdown2 "^" + $delimiter, regular;
if( !result ) return;
beginsel;
searchdown "^" + $delimiter, regular;
if( !result ) {
escape;
return;
}
} else {
gofileend;
beginsel;
searchup "^" + $delimiter, regular;
if( !result ) {
escape;
return;
}
}
rangeeditin;
searchdown $a, loop;
if( result ){
selectall;
copy;
if( #i == 1 ) {
openfile "/h";
insert "【「" + $a + "」の検索結果】\n";
#rep = hidemaruhandle(0);
} else setactivehidemaru #rep;
insert $file[#i] + "\n";
paste;
gofileend;
insert "\n\n";
setactivehidemaru #object;
}
rangeeditout;
return;
//-----------------------------------------------------
山紫水明
|
|