1 Reply Latest reply on Dec 5, 2011 7:28 AM by Marc Autret

    length property in Text-Objects

    grefel Level 2

      I hope this is not an an old one ... I just found this remarkable inconsistency in the InDesign DOM.


      In general the length property shows the number of objects in the collection. Text-Objects have a length property too, the documentation says: "The number of objects in the collection" which does not make sense here. As far as I can see length from a Text-Object gives you the number of Characters of the Object, it looks like a shortcut for characters.length.




        • 1. Re: length property in Text-Objects
          Marc Autret Level 4

          Hi Gregor,


          Well, it's not the first time the doc is totally misleading! Obviously the length property of a Text object is not "The number of objects in the collection", because a Text object is not a collection! (A Texts object is a collection.)


          The Text object is a kind of abstract “class”—like PageItem regarding page items—that wraps any type of text components (Character, Word, Paragraph, InsertionPoint…). Any text component (including Text itself) has a length property that returns the number of addressed characters. E.g.: myWord.length==5, myInsertionPoint.length==0, myText.length==3, etc. Another point is that the interface of any Text object is inherently recursive in that it provides a set of collection properties (Characters, Words, InsertionPoints, Texts…) that reflect various way of selecting text indices within the text object. Then, any DOM collection also has a length property which returns the number of objects within that collection. But do not confuse myText.length and myText.texts.length (which by the way is always less than or equal to 1, AFAIK).