5 Replies Latest reply on Mar 27, 2017 6:47 AM by Marc Autret

    Why do Arrays like allPageItems, allTextFrames etc. not reflect index number properties?

    MasterDomino Level 1

      Hi there,
      I am currently trying to implement a tool for inspecting all sorts of data types and their properties using the reflect() method. While playing around with the reflection results, I noticed that normal Arrays return number index properties (0, 1, 2 etc.) as one would expect, but for some reason special Arrays that hold all items of a container, like allPageItems, allTextFrames etc. do not contain these number properties, although they appear to have a length greater than 0.


      See this example:

      // @target InDesign
      var testArray = ["foo", "bar", "baz"];
      $.writeln(testArray);                           // --> foo,bar,baz
      $.writeln(testArray.length);                    // --> 3
      $.writeln(testArray.reflect.properties);        // --> 0,1,2,length,__proto__
      var doc = app.documents.add();
      $.writeln(doc.zeroPoint);                       // --> 0,0
      $.writeln(doc.zeroPoint.length);                // --> 2
      $.writeln(doc.zeroPoint.reflect.properties);    // --> 0,1,length,__proto__
      $.writeln(doc.allPageItems);                    // --> [object Oval],[object TextFrame],[object Rectangle]
      $.writeln(doc.allPageItems.length);             // --> 3
      $.writeln(doc.allPageItems.reflect.properties); // --> length,__proto__

      As you can see the last array (allPageItems returns a length of three, but does not return properties like 0, 1, 2, unlike the other Arrays.


      Does anyone know why that is? Would be great, if I could just make use of reflection as I can with the normal Arrays.


      Thanks for your help!




      P.S.: InDesign CS6, OS X 10.8.5.