AppleScript 'choose from list'. How can I run a different command if multiple sections are chosen?

Solution 1:

One possible answer:

set choices to {"Render Node 1", "Render Node 2", "Render Node 3"}
set answer to choose from list choices ¬
    with prompt "What would you like to do?" with multiple selections allowed and empty selection allowed
if answer is not false and length of answer is not 0 then
    set delimiter to ""
    set counter to 1
    set value to "Render Node "
    repeat with appitem in choices
        if answer contains appitem then
            set value to value & delimiter & counter
            set delimiter to " & "
        end if
        set counter to counter + 1
    end repeat
    set value to value & " App"
    -- tell application value to activate
    display dialog value
end if

or maybe:

set applist to {¬
    "Render Node 1 App", ¬
    "Render Node 2 App", ¬
    "Render Node 1 & 2 App", ¬
    "Render Node 3 App", ¬
    "Render Node 1 & 3 App", ¬
    "Render Node 2 & 3 App", ¬
    "Render Node 1 & 2 & 3 App"}
set choices to {"Render Node 1", "Render Node 2", "Render Node 3"}
set answer to choose from list choices ¬
    with prompt "What would you like to do?" with multiple selections allowed and empty selection allowed
if answer is not false and length of answer is not 0 then
    set counter to 1
    set value to 0
    repeat with appitem in choices
        if answer contains appitem then
            set value to value + counter
        end if
        set counter to counter * 2
    end repeat
    set value to item value of applist
    -- tell application value to activate
    display dialog value
end if