Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

wilsonbiggs

macrumors newbie
Original poster
Jul 26, 2011
3
0
I'm writing an app bundle, and an IF function won't work. I can't use end if, else if, or else... The error is "Expected end of line, etc. but found 'else if'".The if statement is marked by <<<<<<. Here's the code:
Code:
display dialog ¬
	"Welcome to the magiccards.info™ Desktop Search!" with title ¬
	"Welcome!"
set search_type to (choose from list {"View as Cards with Scans", "View as a List (Oracle)", "View as Checklist", "View as Scans only", "View as a Spoiler"} with prompt "What type of search will you choose?") as string
if search_type is "View as Cards with Scans" then set type_search to "card" <<<<<<
else if search_type is "View as Cards with Scans" then set type_search to "card"
else if search_type is "View as a List (Oracle)" then set type_search to "olist"
else if search_type is "View as Checklist" then set type_search to "list"
else if search_type is "View as Scans only" then set type_search to "scan"
else if search_type is "View as a Spoiler" then set type_search to "spoiler"
end if
set search_item to text returned of (display dialog ¬
	"What card will you search for?" with title ¬
	"magiccards.info™ Desktop Search" default answer ¬
	"" buttons {"Cancel", "Search"} ¬
	default button 2)
set AppleScript's text item delimiters to " "
set theTextItems to text items of search_item
set AppleScript's text item delimiters to "+"
set search_item to theTextItems as string
set AppleScript's text item delimiters to {""}
tell application "Safari"
	make new document at end of documents
	set URL of document 1 to "http://magiccards.info/query?q=" & search_item & "&v=" & type_simple & "&s=cname"
end tell
 
Last edited:
I'm no AppleScript expert but does the part after the then have to be on a separate line?

E.g.,
Code:
if search_type is "..." then
  set type_search to "card"
else if search-type is "..." then
  ...
end if
 
I don't really know anything about applescript, but I would try to simplify the code and then build it up when you get it working. Just get a simple if statement to work first. Maybe add some echo commands if that's possible, to see where the code breaks.
 
If you are sending it through a bunch of IF statements you might try a SWITCH to find the right selection.
 
I'm no AppleScript expert but does the part after the then have to be on a separate line?

E.g.,
Code:
if search_type is "..." then
  set type_search to "card"
else if search-type is "..." then
  ...
end if

Thank you SO much! That worked! :D

@Larswik: What's that? :confused:
 
I did not know it was apple script. I was learning Objective C and my brain went to that. I just used a Switch (case) statement the other day to eliminate a 12 IF statements. I know nothing about Apple Script, sorry.
 
I did not know it was apple script. I was learning Objective C and my brain went to that. I just used a Switch (case) statement the other day to eliminate a 12 IF statements. I know nothing about Apple Script, sorry.

Okay! Thanks for trying! :p
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.