I'm writing a script that can open and close apps for me. Basically, I type in an app name, and then it opens the app. The only thing is, if the app isn't found, it throws an error and quits. I want to make the script just display a dialog that says something like "App not found".
Here's what I have so far:
if userInput contains "Activate " then set {TID, text item delimiters} to {text item delimiters, {"Activate "}}
if length of userInput is less than or equal to 1 then say (resultString as string)
if length of userInput is greater than or equal to 2 then set resultString to text item 2 of userInput
set openApp to (resultString as string)
if userInput contains "Activate " then set text item delimiters to TID
if userInput contains "Activate " then tell application (openApp as string) to activate
BTW, this is just a snippet of my script, which is why there are some undefined variables here.
I tried:
set appList to do shell script "cd /Applications; ls"
if openApp is not in appList then display dialog "App not found"
Huh, Applescript syntax can be so annoying sometimes.
Thanks.