2016-12-14 11 views
0

AppleScriptでハンドラを扱うことを学ぶ問題が発生しました。現在、私は実行時にハンドラを呼び出すようにアプリケーションをトリミングしましたが、現在エラーが発生しています:AppleScriptハンドラがtell Finderブロック内から呼び出されたときに機能しない

error "Script Editor returned error -1708" number -1708 

コンパイルするときに問題はありません。私が解決策を研究しようとすると、アプリケーションFinderの下でこれが機能しない理由を見つけることができません。メモリには、on runをアプリケーションで最後に宣言する必要があることを思い出してください。

コード:

on checkForRebels(tieFighter, starDestroyer) 
    display dialog "dark enough" as text 
end checkForRebels 

on run 
    tell application "Finder" 
     set the starDestroyer to (choose folder with prompt "Please select the Destroyer") 
     set tieFighter to items of starDestroyer 
     checkForRebels(tieFighter, starDestroyer) 
    end tell 
end run 

は私が

applescript items throw error when passing to handler

を探してみましたが、私は私の質問に答えていないAppleのWorking with Errorsを返しました。 Appleの文書About Handlersを確認するときに、問題の内容を開示するものは何も表示されません。

私は私のスクリプトを変更する

on checkForRebels(tieFighter, starDestroyer) 
    display dialog "dark enough" as text 
end checkForRebels 

on run 
    tell application "Finder" 
     set the starDestroyer to (choose folder with prompt "Please select the Destroyer") 
     set tieFighter to items of starDestroyer 
    end tell 
    checkForRebels(tieFighter, starDestroyer) 
end run 

それはどんな問題なく動作しますが、なぜハンドラcheckForRebels()はアプリケーションのFinderのtellブロックでは動作しませんか?私がハンドラを呼び出すときには、常にアプリケーションの外でそれを動作させる必要がありますか?

答えて

1

tellブロックや他のハンドラからハンドラを呼び出す場合は、 "my"を指定する必要があります。そうでない場合は、Finder dicitonaryでそのコマンドを探しています。 AppleScript言語ガイドCalling Handlers in a tell Statementから

my checkForRebels(tieFighter, starDestroyer) 

To call a handler from within a tell statement, you must use the reserved words of me or my to indicate that the handler is part of the script and not a command that should be sent to the target of the tell statement.

関連する問題