-- ステートリスナーを登録する require "asi" -- nspire の asi の現在のステートを監視するステートリスナーを定義する。 -- 現在の asi のステート(on、starting、unsupported のいずれかの文字列)が nspire から渡される。 function stateListener(asiState) print(asiState) -- 確認のため現在の asi のステートを表示する。 end -- 上で定義したステートリスナーを登録する。 asi.addStateListener(stateListener)
スクリプトを実行するとすぐに asi が起動し(starting)、直後に asi の準備が整う(on)。
コールバックは下のように無名函数にしてもよい。
require "asi" asi.addStateListener(function(asiState) print(asiState) end)