title: Display dialog if a word isn't on a list applescript
body: <p>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". </p>
  
  <p>Here's what I have so far: </p>
  
  <pre><code>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
  </code></pre>
  
  <p>BTW, this is just a snippet of my script, which is why there are some undefined variables here.</p>
  
  <p>I tried:</p>
  
  <pre><code>set appList to do shell script "cd /Applications; ls"
  if openApp is not in appList then display dialog "App not found"
  </code></pre>
  
  <p>Huh, Applescript syntax can be so annoying sometimes.</p>
  
  <p>Thanks.</p>