1 Reply Latest reply on Jan 23, 2013 10:57 PM by Vamitul

    How to properly change the content of text item object

    jkinsman Level 1

      Working in CS3 here.

       

      I have a collection of text item objects from a grep search.

       

      I want to iterate through the items and possibly change the values depending on a conditional statement.

       

      So say I have a collection myTextObject that contains text item objects from a GREP search

      <code>

      for (var i = 0; i<myTextObject.length; i++) {

           if (myTextObject[i].content == "myCondition") {

                myTextObject[i].content = "My New Value";

           }

      }

      </code>

       

      Once I do that, all the other content values in my collection are one byte off. So I am guessing that when the collection is created, Indesign sets a byte limit on the collection and when content is replaced, it sets everything off.

       

      I understand that the collection is built from the beginning of the document so possibly iterating backward would solve the problem?

       

      Any other suggestions here?