//指定キーワードを含む行をリストアップするマクロ //listup.mac ver0.2 //(C)2005 hiro //http://cinema1987.org/diary/?date=20050131#p02 $basename2 = basename2; copy2; beginclipboardread; $clip = getclipboard; question "クリップボードに「" + $clip + "」があります。\n このキーワードのある行をリストアップしますか?"; if(result==yes){ $key=$clip; call chksub; }else{ $key=input("リストアップしたい行のキーワードを入力してください"); call chksub;} endmacro; chksub: if(imestate == 1){ if(strlen($key) == 2){ question "「" + $key+"」は全角1文字です。\nそれでも実行しますか?"; if(result==yes){call keysub;} else{endmacro;} } } if(strlen($key) ==1){ question "「"+$key+"」は半角1文字です。\nそれでも実行しますか?";} if(result==yes){ message "「" + $key + "」のある行をリストアップします。\n中止する場合はESCキーを押してください。"; call keysub; }else{endmacro;} return; keysub: if($key==""){ message "何もせずにマクロを終了します。"; endmacro; }else{ title "リストアップ中...中止する場合はESCキーを押してください"; #count=0; gofileend; #lineno=lineno; gofiletop; #lineno2=lineno; golinetop; #i = 0; while(#lineno2 < #lineno){ searchdown $key; if(result==yes){ copyline; beginclipboardread; $lineno3[#i] = str(lineno); $word[#i] = getclipboard; down; golinetop; #i = #i+1; #count=#count + 1; }else{break;} } if(#count==0){ message "キーワード「"+$key+"」は見つかりませんでした。"; }else{ if(basename != ""){ openfile "/h "+""; #i2 = 0; while(#i2 < #i){ insert $basename2 + " " "(" + $lineno3[#i2] + ")" + ": " + $word[#i2]; #i2 = #i2+1;} }else{ openfile "/h "+""; #i2 = 0; while(#i2 < #i){ insert $word[#i2]; #i2 = #i2+1;} } $count=str(#count); message "「" + $key + "」のある行を\n" + $count + "行リストアップしました。"; } } clearcliphist; setclipboard $key; return;