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

Popular posts from this blog

how to insert data php javascript mysql with multiple array session 2 -

multithreading - Exception in Application constructor -

windows - CertCreateCertificateContext returns CRYPT_E_ASN1_BADTAG / 8009310b -