2017-02-01 5 views
-1

関連するコードは次のとおりです。I 最後に "repeat"ブロックでエラーが発生しています。プログラムの実行に使用されるコマンドラインは、 "osascript Export¥Library.scpt/Users/bryandunphy/Development/iTunesLibraryConsolidator Testing.xml"です。Export Library.scpt:実行エラー:変数ndxが定義されていません。 (-2753)であり、2つの認識された変数と同じ "ローカル"行にある

on run (clp) 
    if clp's length is not 2 then error "Incorrect Parameters" 
    local destination, libraryName, ndx 
    set destination to clp's item 1 
    set libraryName to clp's item 2 
    menuClick({"iTunes", "File", "Library", "Export Library…"}) 
    tell application "System Events" to set the value of text field "Save As:" of window "iTunes" of process "iTunes" to libraryName 
    tell pop up button 1 of group 1 of window "iTunes" of process "iTunes" of application "System Events" to click 
    ndx = 1 
    repeat 
     if the title of menu item ndx is "" then 
      select menu item (ndx - 1) 
      exit repeat 
     else 
      ndx = ndx + 1 
     end if 
    end repeat 
    my switchDir(destination, "iTunes", "iTunes", true, false) 
    tell button "Save" of window "iTunes" to click 
    return (destination & "/" & libraryName & ".xml") 
end run 

答えて

0

言語の意味の混乱があります。

localステートメントは変数を宣言しますが、(Cのように)値を定義しません(値を代入しません)。

ステートメント

ndx = 1 

(それを定義する)可変ndxに(現在定義されていない)1変数ndx

set ndx to 1 

assignes値1を比較します。

と似

set ndx to ndx + 1 

ラインtell pop up button 1 ...後さらにすべてがSystem Events tellブロック

+0

内でなければならないシステム内でなければなりません...ボタン1をポップアップ教え行の後にさらにすべてのもの」に拡大してくださいイベントはブロックを示します。 **正確に***どの行が "tellブロック"の中にある必要がありますか? –

+0

実際には 'menu item'と' tell button "という行を含む2行が" ... " – vadian

関連する問題