2009-08-30 5 views
0

私がこれまでにAppleScriptを次ていますAppleScriptの値をリストしますか?

# List of possible options to control the development environment. 
set WhatDoUWantToDoList to {"1", "2", "3", "4"} 

set MySites to {"test1", "test2"} 

# task selected 
set selectedTask to {choose from list WhatDoUWantToDoList with prompt "Pick your task now!!!" without multiple selections allowed} 

if selectedTask is equal to {"1"} then 
    display dialog selectedTask 
else 
    # site selected 
    set selectedSite to {choose from list MySites with prompt "Pick the site your working on!!!"} 

    if (selectedTask is not equal to false and selectedSite is not equal to false) then 
     display dialog selectedTask 
     display dialog selectedSite 
    else 
     display dialog "you messed up!" 
    end if 
end if 

私は、他のオプションは、リスト1で選択されている場合しかし、あなたがする必要がある、オプション1は、リスト1の表示にのみ選択したタスクを選択した場合に言おうとしています新しいコードブロックに移動し、リスト1とリスト2をキャンセルした場合、リスト2のオプションを選択する必要があります。

私はここで何が不足しているかに関するアイデアはありますか?

答えて

0

が働いた:selectedTaskは「1」が含まれている場合、複数選択が可能ですので、その後

5

{ }はリストを作成するので、selectedTaskを設定すると、choose from listの結果が別のリストに追加されます。結果を{"1"}と比較しようとすると、実際には{{"1"}}なので、等しくはありません。

代わりに括弧()を使用してください。このコードを使用して

+1

私はまだ1が、それは仕事のために、もしブロックを入力し、私はそれを実行するたびに、それはまだ両方実行し、停止する必要が選択されている場合は、それがあればブロック

 if selectedTask is equal to {{"1"}} then \t \t display dialog selectedTask \t else 
を入力することができませんif文の一部 –

+0

問題を間違った場所で解決しています。 '{あなたの仕事を今すぐ選んでください!!!]プロンプトでWhatDoUWantToDoListのリストから選択してください。複数の選択が許されない} 'with()。 –

0

リストから選択し、常に配列を返します。基本的な考え方は次のとおりです。

set selectedValues to (choose from list {"Value 1", "Value 2"} with prompt "Choose") 
if (selectedValues is not false) then 
    set selectedValue to item 1 of selectedValues 
    display dialog ("You chose " & selectedValue as text) 
else 
    display dialog ("You did not chose!") 
end if 
関連する問題