Home>History>

2010.02

2010-02-24

2010-02-24T19:50:42+09:00

HaloScan から google friend connect に移行した。

HaloScan がサービスを停止してしまったようなので、google friend connect に移行した。頂いたコメントは保存してあるけど google friend connect に移行するにはどうやったらいいのか分からん。

google friend connect は HaloScan より、だいぶ高機能でいろいろできるみたいだけど、見た目のカスタマイズが難しい。文字サイズの変更の仕方が分からん。「コメント(0)」が本文よりでかい文字で並んでいるのをどうにかしたいのだけど。

2010-02-21

2010-02-21T18:36:38+09:00

ちゃらんぽらんさんの「load Script 命令におけるスクリプトの再利用」へのコメント

ちゃらんぽらんさんが、AppleScript でのモジュールの活用について解説を始められている。興味のある分野なのでコメントしちゃう。サンプルとしてFinder の選択項目の処理のモジュール化を取り上げられている。

結論から言って、僕なら次のようにする。まず、モジュール FinderUtility は次のようにする。

property action : missing value

on run
set_action(LabelOrange)
my process_Finder_selection()
set_action(ToggleLock)
my process_Finder_selection()
end run

on process_Finder_selection()
tell application "Finder"
set selected_items to selection
if selected_items is {} then return

repeat with this_item in selected_items
my action's do(this_item)
end repeat
end tell
end process_Finder_selection

on set_action(an_action)
set my action to an_action
end set_action

script LabelOrange
on do(this_item)
tell application "Finder"
set label index of this_item to 1
end tell
end do
end script

script ToggleLock
on do(this_item)
tell application "Finder"
set locked of this_item to not (locked of this_item)
end tell
end do
end script

on use_label_orange()
set_action(LabelOrange)
end use_label_orange

on use_toggle_lock()
set_action(ToggleAction)
end use_toggle_lock

上のスクリプトは、FinderUtility.scpt としてデスクトップに保存されているとする。この FinderUtility をロードするトップレベルスクリプトは次のようにする。

set the_folder to path to desktop as text
set the_file to the_folder & "FinderUtility.scpt"

set FinderUtility to load script file the_file

tell FinderUtility
-- 選択項目のラベルをオレンジに
use_label_orange()
process_Finder_selection()
delay 1
-- 選択項目のラベルをなしに
set_action(LabelNone)
process_Finder_selection()
end tell

script LabelNone
on do(this_item)
tell application "Finder"
set label index of this_item to 0
end tell
end do
end script

ちゃらんぽらんさんのコードからの変更のポイントは、まず、モジュールの外部インターフェースとしてはハンドラだけに限定すること。スクリプトオブジェクトのプロパティを直接書き換えるようなことはしない。プログラムの一般論でも、僕の経験でも、こうしないと将来つらい思いをします。

そうするとハンドラをモジュールに渡すということはできなくなる。従って、コードをスクリプトオブジェクト間でやり取りするには、スクリプトオブジェクト使うようにする。set_action というハンドラを用意して、その引数にスクリプトオブジェクトを渡しているところがこれに相当する。

人のコードを勝手に添削してごめんなさい。

2010-02-19

2010-02-19T15:19:20+09:00

TeXCompileServer Icon TeX Tools for mi 3.3.9

テキストエディタ mi を中心とした LaTeX の統合環境を提供するアプリケーションとスクリプトのセットです。より高機能なTeX の統合環境を実現します。

mi 2.1.10b1 と一緒に使うとエラーが発生する不具合を修正しました。高橋さん、ありがとうございました。

2010-02-16

2010-02-16T01:17:46+09:00

XDict 1.6

XDict は AppleScript で連想配列のデータ構造を提供するモジュールです。連想配列とはキー値に対応して値を設定した配列です。

連想配列とは・・・record クラスにいくらか似ており、ラベルをスクリプトの実行中に新しく作ることができたり、変数で指定したりすることができるものと考えて大間違いないでしょう。

2010-02-03

2010-02-03T00:09:41+09:00

XText 1.2

テキスト操作をオブジェクト指向で行うための、AppleScript のテキストオブジェクトのラッパーオブジェクトです。文字列の置換や分割、空白の除去など様々なテキスト操作をオブジェクト指向のスタイルで行うことができます。