
mi で選択している文字列を反時計回りに回転するアップルスクリプトです。
あか
いき
うく
えけ
おこ上のような文字列を反時計回りに回転して、
かきくけこ
あいうえおこんな感じにします。
tell application "mi" tell document 1 -- 変数の初期化 set ColCount to 0 set NewData to "" -- mi の選択範囲を取得する set OldData to selection -- 現在のデリミタ値を保存 set LastDelimiter to AppleScript's text item delimiters -- デリミタを改行に設定 set AppleScript's text item delimiters to return -- デリミタでリストに分解 set OldData to every text item of OldData -- 行数を取得する(最終行の改行文字を選択している場合の処理) set RowCount to (count of OldData) - 1 -- デリミタを空白文字に設定 set AppleScript's text item delimiters to "" -- 行数分ループ repeat with i from 1 to RowCount -- 最大文字数を取得する if ColCount < (count of item i of OldData) then set ColCount to (count of item i of OldData) end if -- 一文字ずつ配列に入れる set item i of OldData to (text items of item i of OldData) end repeat -- 行列置換 repeat with x from ColCount to 1 by -1 repeat with y from 1 to RowCount try set NewData to NewData & text item x of item y of OldData on error set NewData to NewData & " " end try end repeat set NewData to NewData & return end repeat -- デリミタを元に戻す set AppleScript's text item delimiters to LastDelimiter -- mi の選択部分に書き戻す copy NewData to selection end tell
end tell動作確認:Mac OS 10.4.9 + mi 2.1.8a7
現場からは以上です。それでは、またッ!!!


