////////////////////////////////////////////////// // CUTFILE.MAC by nyan // 秀丸マクロ // // 説明 // // 1つのファイルを多数のファイルに分割したいときに使います。 // 分割してできるファイルの名前は、$file=filename という書式のコマンドと // して、テキスト中に書き込んでおきます。コマンドは必ず行頭に書き、最後に // 改行記号か半角スペースがついていなくてはなりません。 // // このマクロは Windows 3.1 のときに作ったまんまで、長いファイル名には対 // 応していないので、生成するファイルにつける名前は、DOS の 8+3 文字とし // てください。 // // $file=file_a.txt // テキストの行頭に $file=file_a.txt と書いてあったら、それ以降のテキスト // を file_a.txt というファイルにコピーします。追加書き込みです。コマンド // の書いてある行自体はコピーしません。 // // $file= // テキストの行頭に $file= とだけ書いてあって、ファイル名がなければ、それ // 以降のテキストはコピーしません。 // // %file=file_a.txt // テキストの行頭に %file=file_a.txt と書いてあったら、$file=file_a.txt と // 同様に、それ以降のテキストを file_a.txt というファイルにコピーします。 // この場合は、コマンドの書いてある行自体もコピーします。 // // %file= // テキストの行頭に %file= とだけ書いてあって、ファイル名がなければ、それ // 以降のテキストはコピーしません。 // ////////////////////////////////////////////////// question "テキストを分割コピーします\n\n コマンド書式:\n $file=file_a.txt (コマンド行を除いて file_a.txt にコピー)\n $file= (コピー中断)\n %file=file_a.txt (コマンド行を含めて file_a.txt にコピー)\n %file= (コピー中断)\n\n 続けますか?"; if(result==no) endmacro; $orgfile=filename; gofiletop; $file=""; while(1) { disabledraw; #x0=x; #y0=y; golineend2; #x1=x; #y1=y; $newline=gettext(#x0,#y0,#x1,#y1); if(leftstr($newline,6)=="$file=") {call copying; call getname;} else if(leftstr($newline,6)=="%file=") {call copying; call getname; $text=$text+$newline+"\n"; call copying;} else if(code==eof) {$text=$text+$newline+"\n"; call copying; endmacro;} else if(strlen($text)+strlen($newline)>3000) { $text=$text+$newline+"\n"; call copying;} else $text=$text+$newline+"\n"; right; } endmacro; copying: if(($text!="")&&($file!="")) { title "copying to "+$file; if(findhidemaru($file)!=-1) setactivehidemaru findhidemaru($file); else if(existfile($file)) openfile "/h "+$file; else {openfile "/h"; changename $file;} golineend; insert $text; save; setactivehidemaru findhidemaru($orgfile); closehidemaru findhidemaru($file);} $text=""; title 0; return; getname: $file=midstr($newline,6,12); #s=strstr($file," "); if(#s>-1) $file=leftstr($file,#s); #s=strstr($file,"<"); if(#s>-1) $file=leftstr($file,#s); #s=strstr($file,">"); if(#s>-1) $file=leftstr($file,#s); #s=strstr($file,"|"); if(#s>-1) $file=leftstr($file,#s); if($file=="") return; #s=strstr($file,"."); if(#s>-1) { $base=leftstr($file,#s); $ext=rightstr($file,strlen($file)-#s-1); } else {$base=$file; $ext="";} if(strlen($base)>8) {$base=leftstr($base,8); call FILENAMEERROR;} if(strlen($base)==0) {$base="________"; call FILENAMEERROR;} #s=strstr($ext,"."); if(#s>-1) {$ext=leftstr($ext,#s); call FILENAMEERROR;} if(strlen($ext)>3) {$ext=leftstr($ext,3); call FILENAMEERROR;} $file=$base+"."+$ext; return; FILENAMEERROR: message $file+" は正しいファイル名でないので\n"+ $base+"."+$ext+" に修正しました"; return; // おわり