title: How do I debug a script relying heavily on an existing Illustrator document?
body: <p>I'm using Adobe Illustrator CS5 and ExtendScript Toolkit CS5.</p>
  
  <p>I've got a very involved script and alert() isn't working anymore because stuff is within a loop. How can I simulate the fact that I'm using a specific Illustrator document so that I can use the debugging features of ExtendScript Toolkit?</p>
  
  <p>I want it to be the same as being inside an Illustrator document and going "File->Scripts->Scriptname". If I just test the script inside ExtendScript, I get an error on </p>
  
  <pre><code>if (app.documents.length &gt; 0) {
  </code></pre>
  
  <p>Thanks!</p>