title: Illustrator scripting JavaScript. have loop use number it is finding
body: <p>I am trying to get coding to find a range of colors and select them. 
  <a href="https://stackoverflow.com/questions/51773047/illustrator-script-to-find-all-colors-in-document">Someone was able to help with this code.</a></p>
  
  <pre><code>with (app.activeDocument) { 
    if (pathItems.length &gt; 0) {
      alert(pathItems.length);
      for (var g = 0 ; g &lt; pathItems.length; g++) {
        if (pathItems[g].filled == true) {
          if (
            pathItems[g].fillColor.red &gt; 200 == true &amp;&amp;
            pathItems[g].fillColor.red &lt; 210 == true &amp;&amp;
            pathItems[g].fillColor.green &gt; 200 == true &amp;&amp;
            pathItems[g].fillColor.green &lt; 210 == true &amp;&amp;
            pathItems[g].fillColor.blue &gt; 200 == true &amp;&amp;
            pathItems[g].fillColor.blue &lt; 210 == true
          )
          {
            alert('R' + pathItems[g].fillColor.red + ' G' + pathItems[g].fillColor.green + ' B' + pathItems[g].fillColor.blue);
          }
        }
      }
    }
  }
  </code></pre>
  
  <p>I have been trying to get it to use the numbers it is finding for the alert and use those as the RGB colors to select</p>
  
  <pre><code>with (app.activeDocument) {
    if (pathItems.length &gt; 0) {
      alert(pathItems.length);
      for (var i = 0 ; i &lt; pathItems.length; i++) {
        if (pathItems[i].filled == true) {
          if (
            pathItems[i].fillColor.red &gt; 200 == true &amp;&amp;
            pathItems[i].fillColor.red &lt; 210 == true &amp;&amp;
            pathItems[i].fillColor.green &gt; 200 == true &amp;&amp;
            pathItems[i].fillColor.green &lt; 210 == true &amp;&amp;
            pathItems[i].fillColor.blue &gt; 200 == true &amp;&amp;
            pathItems[i].fillColor.blue &lt; 210 == true
          );
  
          var newRGBColor = pathItems[i].fillColor.red &amp;&amp;
                            pathItems[i].fillColor.green &amp;&amp;
                            pathItems[i].fillColor.blue; 
          {
            app.activeDocument.defaultFillColor = newRGBColor;
            app.executeMenuCommand("Find Fill Color menu item"); 
          }
        }
      }
    }
  }
  </code></pre>
  
  <p>But this is not working. I am very much of not a coder my brain just can understand it. I know the basics but, that is about all can my brain will retain. This is about my 100th version of this code. I am really trying, so please don't be mad at me if i am missing something. 
  I have taken a javascripting class, read the illustrator scripting guilds, and am all over W3schools. My brain just can not understand much for coding, so please please do not get mad at me. I really am just looking for help.</p>
  
  <p><em>Updates</em></p>
  
  <p>Thank you for letting me know <code>with</code> is out dated but, I got this coding from someone else as shown on top and i dont know enough to update things. What i am trying to get it to do is Find the RGB color breakdowns in Illustrator on objects.  <code>app.activeDocument.defaultFillColor</code> will change my set my default color fill and <code>app.executeMenuCommand("Find Fill Color menu item")</code> will fine the color i have selected(default color if not one selected) </p>
  
  <pre><code> if (
     pathItems[g].fillColor.red &gt; 200 == true &amp;&amp;
     pathItems[g].fillColor.red &lt; 210 == true &amp;&amp;
     pathItems[g].fillColor.green &gt; 200 == true &amp;&amp;
     pathItems[g].fillColor.green &lt; 210 == true &amp;&amp;
     pathItems[g].fillColor.blue &gt; 200 == true &amp;&amp;
     pathItems[g].fillColor.blue &lt; 210 == true
   )
  </code></pre>
  
  <p>This will find the colors i need to select but i can get my defaultFillColor to be the colors for the code before</p>