2017-02-12 4 views
1

Ich habe versucht, ein Skript zu erstellen, das Ihnen 3 verschiedene Aktionen über ein Dialogfeld ermöglicht, aber wenn ich sie ausprobiere, funktioniert nur die erste Option. Gibt es einen Workaround dafür, da dies der Mittelpunkt meines Programms ist? Jede Hilfe wird geschätzt und danke im Voraus!Anzeigedialog mit 3 Ergebnissen?

set myQuery to display dialog "selection?" buttons {"choice 1", "choice 2", "choice 3"} 
if the button returned of myQuery is "choice 1" then do script 
if the button returned of myQuery is "choice 2" then do script 
if the button returned of myQuery is "choice 3" then do script 

In diesem Fall funktioniert nur die Auswahl eines Skripts und die anderen beiden Fehler.

Antwort

0

Sie waren auf dem richtigen Weg. Dies sollte für Sie arbeiten

set myQuery to display dialog "selection?" buttons {"choice 1", "choice 2", "choice 3"} 
if button returned of myQuery is "choice 1" then 
    say "you selected choice one" --replace this line with what ever you want 
end if 
if button returned of myQuery is "choice 2" then 
    say "you selected choice two" --replace this line with what ever you want 
end if 
if button returned of myQuery is "choice 3" then 
    say "you selected choice three" --replace this line with what ever you want 
end if 
+0

Danke für die Antwort. Es ist mir unangenehm, dass ich so nahe war, aber jetzt habe ich die Antwort. Danke nochmal für deine Hilfe! :) – user7439349

+0

Glaub mir, ich verstehe die Frustration. Ich bin neu in AppleScript und die einzige Lösung, die ich mir vorstellen kann, ist lesen lesen und üben üben üben. Es macht aber Spaß ... Der ganze Prozess. – wch1zpink

0

Es gibt eine Menge von Redundanz im Code und drei separate if Klauseln sind nicht effizient.

set {button returned:myQuery} to display dialog "selection?" buttons {"choice 1", "choice 2", "choice 3"} 
if myQuery is "choice 1" then 
    say "choice one" 
else if myQuery is "choice 2" then 
    say "choice two" 
else 
    say "choice three" 
end if 
+0

Danke für das Heads-Up. Ich lerne immer noch, aber ich weiß es zu schätzen, dass du es aufgezeigt hast. – wch1zpink

Verwandte Themen