0

私はこれまでに次の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で他のオプションが選択されている場合は、新しいコードブロックに移動する必要があり、リスト2でオプションを選択する必要があります。あなたはリスト1とあなたが台無しにしたリスト2でキャンセルします。

私がここで欠けているものについて何かアイデアはありますか?

4

3 に答える 3

5

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

( )代わりに、グループ化には括弧を使用してください。

于 2009-08-30T02:50:52.103 に答える
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
于 2009-10-08T18:45:40.263 に答える
0

このコードを使用するとうまくいきました:selectedTaskに「1」が含まれている場合

于 2009-08-31T00:51:54.347 に答える