> so I count on your taking me seriously next time <br /><br />Maybe you're not taking me seriously. I was asking a simple question: what is the purpose of an if() (or even a portion of an if()) that always returns true?<br /><br />As I understand it, Javascript if() does not return true or false when you put one of the elements of an array in it. It returns the element's value. If the element does not exist, the return is not null or undefined, because the element's value is not null or undefined; the element can't be found to be evaluated.<br /><br />You can see this if in your script you do:<br /><br />alert(paraStyles.getByName("Caption"));<br /><br />What will be returned is not true or false, but [ParagraphStyle Caption].<br /><br />try it again with:<br /><br />alert(paraStyles.getByName("Caption")==true);<br /><br />If the style exists, you get false. If the style does not exist you'll get the element not found error.<br /><br />Evidently this is not peculiar to Illustrator. This understanding seems to be borne out all over the web by the presence of various workarounds designed expressly to check for the existence of an element in a Javascript array, like you can in PHP via the in_array function.<br /><br />One such workaround is described <a href="http://snook.ca/archives/javascript/testing_for_a_v/">here</a>. There are others.<br /><br />So if paragraphStyles.getByName() does not find the referenced element, it is not going to return false; it is going to return the element not found error.<br /><br />It seems unavoidable, then, if you are trying to test for the presence of a Paragraph Style named "Caption", to use a loop to check for the occurrence of the name within the collection. Something like:<br /><br />var docRef=app.activeDocument;<br />var pStyles=docRef.paragraphStyles;<br /><br />var styleNameSought="Caption";<br />var foundIt=false;<br /><br />for(i=0;i<pStyles.length;i++){<br /><br />var currStyleName=pStyles.name;<br /><br />if(currStyleName==styleNameSought){<br /><br />foundIt=true;<br />}<br /><br />}<br /><br />alert(foundIt);<br /><br />JET