Reputation: 35
I am creating a small program and one of my functions is a dictionary. I need a way to split the subjects though but for some reason my code won't work. I keep getting the error "Expected “else”, etc. but found “end tell”." for this code:
set math_list to {"math", "Math"}
set science_list to {"science", "Science"}
set history_list to {"History", "history", "Social Studies", "social studies", "socialstudies"}
set reading_list to {"writing", "reading", "grammar", "Grammar", "Reading"}
set no_list to {"no", "not really", "I am ok", "I am good", "I am good"}
set complete_list to reading_list & math_list & science_list & no_list & history_list
tell application "SpeechRecognitionServer"
set theResponse to listen for complete_list with prompt "Would you like to search under the subject math, science, history, or reading"
if theResponse = "writing" then
set theResponse to "reading" --Otherwise you would get a very weird sentence
else if theResponse = "grammar" then
set theResponse to "reading" --Otherwise you would get a very weird sentence
if (math_list contains theResponse) then
say "Opening Google Chrome"
launch application "Google Chrome"
else if (science_list contains theResponse) then
say "Opening Google Chrome"
launch application "Google Chrome"
else if (history_list contains theResponse) then
say "Opening Google Chrome"
launch application "Google Chrome"
else if (reading_list contains theResponse) then
say "Opening Google Chrome"
launch application "Google Chrome"
else if (no_list contains theResponse) then
say "Ok then"
end tell
end tell
Upvotes: 0
Views: 72
Reputation: 35
This is the answer that worked for me. Thank you Craig Smith:
You will also find that simply typing end at the conclusion of a repeat, tell, or if section will automatically be compiled into the correct type of end needed:
tell app "itunes" repeat 5 times if exists playlist "Purchased" then play track 7 of playlist "Purchased" end end end is subsequently compiled into:
tell application "iTunes" repeat 5 times if exists playlist "Purchased" then play track 7 of playlist "Purchased" end if end repeat end tell Learning to use that style of entering code will speed up your production and greatly reduce errors and problems.
Good luck,
Upvotes: 0
Reputation: 1071
You will also find that simply typing end at the conclusion of a repeat, tell, or if section will automatically be compiled into the correct type of end needed:
tell app "itunes"
repeat 5 times
if exists playlist "Purchased" then
play track 7 of playlist "Purchased"
end
end
end
is subsequently compiled into:
tell application "iTunes"
repeat 5 times
if exists playlist "Purchased" then
play track 7 of playlist "Purchased"
end if
end repeat
end tell
Learning to use that style of entering code will speed up your production and greatly reduce errors and problems.
Good luck,
Upvotes: 2