2 Replies Latest reply on Nov 9, 2011 6:41 AM by ikitzmann

    How does everyItem().name work?

    ikitzmann

      Hello,

       

      I have found in some other post or howto the following InDesign Javascript line, which gives me an array with all names of the pdf export presets.

       

      var availablePdfPresets = app.pdfExportPresets.everyItem().name;
      

       

      I am curious how this technically works.

       

      app.pdfExportPresets

      gives me an object (PDFExportPresets) which has an function "everyItem()". So far so good. But how does the 

      everyItem().name;

      combines all "name" properties from the different pdf export preset objects to one array?

       

      This does not affect my current work, but I would like to understand the techniques behind. And perhaps I might be able to use this knowledge some day in my own projects.

       

      Is anybody able to explain this?

        • 1. Re: How does everyItem().name work?
          TᴀW Adobe Community Professional & MVP

          Some here will be able to explain this better than I can. But consider

          that everyItem().getElements() returns an array of all the objects (ie

          app.documents.everyItem().getElements() will return an array of all the

          documents.)

           

          So everyItem().name returns an array of only the name of the elements,

          rather than the entire elements themselves, which you can get with

          getElements().

           

          everyItem() is like a "potential" list of all elements, but InDesign

          does not actually access all those elements until your bring it down to

          earth with something like getElements().

           

          As I say, others here can explain this better. I remember reading about

          this on, I think, Marc Autret's website, but I don't have the link to

          hand. He has an excellent exposition of this entire subject.

           

          Ariel

          1 person found this helpful
          • 2. Re: How does everyItem().name work?
            ikitzmann Level 1

            Arïel wrote:

            As I say, others here can explain this better. I remember reading about

            this on, I think, Marc Autret's website, but I don't have the link to

            hand. He has an excellent exposition of this entire subject.

             

            Thank you very much. Your hints and a Google search led me to the correct entries on his website:

            http://www.indiscripts.com/post/2010/06/on-everyitem-part-1

            http://www.indiscripts.com/post/2010/07/on-everyitem-part-2

            These posts describe this in detail. Thank you!