Applescript Syntax Error "Expected “else”, etc. but found end of script." -
i having trouble in applescript:
display dialog "open application" buttons {"chrome", "applescript", "textedit"} set button_pressed button returned of result if button_pressed "chrome" open application "google chrome"-- action 1st button goes here if button_pressed "applescript" open application "applescript editor"-- action 2nd button goes here if button_pressed "textedit" open application "textedit"-- action 3rd button goes here end it keeps saying syntax error: expected “else”, etc. found end of script.
what should do
you have 3 if statements, end 1 of them.
what want here else if:
display dialog "open application" buttons {"chrome", "applescript", "textedit"} set button_pressed button returned of result if button_pressed "chrome" open application "google chrome" -- action 1st button goes here else if button_pressed "applescript" open application "applescript editor" -- action 2nd button goes here else if button_pressed "textedit" open application "textedit" -- action 3rd button goes here end if (also, you're supposed use end if, not end, applescript editor fix you.)
alternatively, end each one:
display dialog "open application" buttons {"chrome", "applescript", "textedit"} set button_pressed button returned of result if button_pressed "chrome" open application "google chrome" -- action 1st button goes here end if if button_pressed "applescript" open application "applescript editor" -- action 2nd button goes here end if if button_pressed "textedit" open application "textedit" -- action 3rd button goes here end if however, cases mutually exclusive, there's not reason not use else if instead.
if helps, type lines in 1 one , see how applescript editor indenting them:
display dialog "open application" buttons {"chrome", "applescript", "textedit"} set button_pressed button returned of result if button_pressed "chrome" open application "google chrome"-- action 1st button goes here if button_pressed "applescript" open application "applescript editor"-- action 2nd button goes here if button_pressed "textedit" open application "textedit"-- action 3rd button goes here end that should make obvious what's wrong.
Comments
Post a Comment