title: Adding a variable to applescript within obj-c
body: <p>Not sure if this one is possible in objective-c without having the script as a file and running it that way.</p>
  
  <pre><code>    NSAppleScript *appleScriptGetHH = [[NSAppleScript alloc] initWithSource:@\
                                "tell application \"System Events\"\n \
                                tell process \"Grabee\"\n \
                                with timeout of 0 seconds\n \
                                get value of attribute \"AXValue\" of text area 1 of scroll area 1 of window \"Demo Window 1" \n \
                                end timeout \n \
                                end tell \n \
                                end tell"];
  </code></pre>
  
  <p>This works perfectly, but what I would like to do is replace "Demo Window 1" with a string (as it will be changed dynamically in the program)</p>
  
  <p>When I use something like this</p>
  
  <pre><code>NSString *windowName = @"Green Window4";
  </code></pre>
  
  <p>And then replace this line:</p>
  
  <pre><code>get value of attribute \"AXValue\" of text area 1 of scroll area 1 of window \"Demo Window 1" \n \
  </code></pre>
  
  <p>With:</p>
  
  <pre><code>get value of attribute \"AXValue\" of text area 1 of scroll area 1 of window \"%@" \n \
  </code></pre>
  
  <p>And </p>
  
  <pre><code>end tell", windowName];
  </code></pre>
  
  <p>I receive an error that there are too many arguments, is there a way to do this without having the script separate?</p>