home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
MacPeople 2003 February 1
/
MACPEOPLE-2003-02-01.ISO.7z
/
MACPEOPLE-2003-02-01.ISO
/
ぶらりオンラインウェアの旅
/
定番ソフト
/
Jedit(OS9)
/
MacroCollectionJ.sea
/
MacroCollection-J
/
分割保存
/
スクリプト解説
< prev
next >
Wrap
Text File
|
2001-01-01
|
2KB
|
60 lines
分割保存マクロ
programmed by Satoshi Matsumoto <satoshi@matsumoto.co.jp>
Jedit4.0で開いている書類を分割保存します。分割境界は正規表現で指定します。
ーーーーーーーーーーーー
分割境界の正規表現、デフォルト値
property borderString : "^-- cut here --"
tell application "Jedit4"
Jeditのバージョンが4.0.4以上かどうかをチェック。そうでない時は中止。
if version < 404 then
preDialog
display dialog "Jedit4.0 Rev4.0.4 以降を使用してください" buttons {" 了解"}
postDialog
error number -128
end if
Jeditの書類を前面へ
activate
書類はなにも開いていないときは警告をだして終了
if (count document) < 1 then
preDialog
display dialog "分割保存する書類を先に開いてください。" buttons {" 了解"}
postDialog
error number -128
end if
preDialog
try
ダイアログで、分割境界の正規表現を指定する
set borderString to text returned of (display dialog "分割境界の先頭パターンを正規表現で指定してください" default answer borderString)
on error
キャンセルボタンを押したときは終了
postDialog
error number -128
end try
postDialog
tell document 1
文字変数thePathにファイルのパス名を保存
set thePath to fileSpec as text
各変数を初期化
set theCount to 0
set theMatchLen to 0
set startOff to 1
set endOff to (count bytes)
分割境界文字列が見つかるまでrepeat文で繰り返す
repeat while (((startOff + theMatchLen) < endOff) and (find borderString in bytes (startOff + theMatchLen) thru endOff with grep without wrap around))
見つかったので、カウンタをインクレメント
set theCount to theCount + 1
set newOff to byteoffset of the selection
set theMatchLen to (length of the selection)
そのstartOffから(newOff - 1)までの部分を、ファイル名に連番をつけて保存
save (bytes startOff thru (newOff - 1)) in file (thePath & "_" & theCount)
set startOff to newOff
end repeat
if startOff < endOff then
まだ保存していない最後の部分を保存
set theCount to theCount + 1
save ( bytes startOff thru endOff ) in file (thePath & "_" & theCount)
end if
end tell
end tell