7 Replies Latest reply on Apr 22, 2013 9:21 AM by indegn5

    Words from index Panel - TOPIC and apply page references.

    indegn5

      Hello All,

       

      After reading the few thread about adding Pagereferences... I need a help.....

       

      I want to add pageReferences using the words listed in index panel / Topics.

       

      Some specific words are listed only Topics and no page references found inside (as some one removed the pagereferences (~I) inside the document.... because of this i cant able to generate INDEX and get page numbers ....

      This tried with this little bit try; the result is nothing;

       

      MyStory  = app.activeDocument.stories.everyItem();

      var PRefs = app.documents[0].indexes.item(0).topics.everyItem().getElements();

      StoryTopics = [];

      for (i = 0; i < PRefs.length; i++)

          if (PRefs  == MyStory)

              PRefs[i].parent.push (StoryTopics);

      MyStory[i].pageReferences.add(PRefs, PageReferenceType.currentPage);

       

       

      thanks forum...

        • 1. Re: Words from index Panel - TOPIC and apply page references.
          indegn5 Level 1

          indexes.png

          To have more clearance on my previous request.... i have attached this..

           

          The above panel has the words listed below the Topic, but inside the document the same words are not referenced... (some one has removed the pageReferences).

           

          eg. the highlighted words in the topic, found inside the document has no index mark (^).

           

          I wish to apply PageReferences to all the words listed  the TOPIC.

           

          thanks forum....

          • 2. Re: Words from index Panel - TOPIC and apply page references.
            indegn5 Level 1

            Well Forum!,,,

             

            Here i got clue to find the topic word and relate to the document text and then add Pagereferences(~I) to the finded word.

             

            But the problem is It find and place the pageReference symbol only for the first found.

             

            I think, here im missing the way of refreshing find and replace and then continuing its process.

             

            Could anybody look atthis script, to make to find and apply all the found instances
            and then to run the taks faster...(I checked, if the document has more than two pages, the script take atleast 30 min to complete and the result is, it applied only for the first instances of the first search).

             

            Please.....Help onthis


            app.findGrepPreferences = app.changeGrepPreferences = null;

            myDoc = app.activeDocument;

            myStory = app.activeDocument.pages.everyItem();

            gwords = app.activeDocument.indexes[0];

            twords = app.activeDocument.indexes[0].topics.everyItem().pageReferences.everyItem().toString();

            var raj = new Array;

            raj.push(twords);

            app.findGrepPreferences = app.changeGrepPreferences = null;

            var findWhat = app.findGrepPreferences.findWhat = (raj).toString();

            founds = app.documents[0].findGrep();

            for (i =0 ; i<founds.length; i++)

            found = founds[i];

            app.select(found);

             

            myDoc.indexes[0].topics[0].pageReferences.add(found, PageReferenceType.currentPage );

            //myDoc.indexes[0].topics.everyItem().pageReferences.add(found, PageReferenceType.currentPage);

            app.findGrepPreferences = app.changeGrepPreferences = null;

            gwords.update();

            var myIndexStory = gwords.generate();

             

            thanks.& regards..

            bob....

            • 3. Re: Words from index Panel - TOPIC and apply page references.
              SureshRaji

              Hi indegn5,

               

              I have a doubt that where the for loop closed in your code.

              • 4. Re: Words from index Panel - TOPIC and apply page references.
                indegn5 Level 1

                Hi Selva,,

                 

                Though the loop have been closed at

                 

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

                found = founds[i];

                app.select(found);

                }

                 

                The programme still run slower, and the find and apply pagereferences occures, only to the first item.

                EG. IF I need to find Apple, Bat, Cat and there are available on page 2,3,4, 5, 6, etc.,

                 

                the Index generated shows only on first page..ie.

                Apple   2

                Bat 2

                Cat 2

                 

                but the other pages nos. 3, 4, 5, 6 which have the same things Apple, Bat, Cat is not shown in the index...

                my result should be..

                 

                Apple   2,3,4,5,6,

                Bat 2,3,4,5,6,

                Cat 2,3,4,5,6,...

                 

                 

                thanks...

                any help to find all the pages and the script to run faster to give the result...

                 

                thanks.

                • 5. Re: Words from index Panel - TOPIC and apply page references.
                  SureshRaji Level 2

                  Hi,

                   

                  Try this

                   

                  app.findGrepPreferences = app.changeGrepPreferences = null;

                  myDoc = app.activeDocument;

                  myStory = app.activeDocument.pages.everyItem();

                  gwords = app.activeDocument.indexes[0];

                  twords = app.activeDocument.indexes[0].topics.everyItem().getElements();

                  app.findGrepPreferences = app.changeGrepPreferences = null;

                  for(j=0; j<twords.length; j++){

                      var findWhat = app.findGrepPreferences.findWhat = twords[j].name;

                      founds = app.documents[0].findGrep();

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

                          found = founds[i];

                          app.select(found);

                          myDoc.indexes[0].topics[j].pageReferences.add(found, PageReferenceType.currentPage );

                      }

                  }

                  gwords.update();

                  var myIndexStory = gwords.generate();

                  • 7. Re: Words from index Panel - TOPIC and apply page references.
                    indegn5 Level 1

                    Hi Suresh,

                     

                     

                    thanks for denoting the loop;;;

                     

                    for(j=0; j<twords.length; j++){

                        var findWhat = app.findGrepPreferences.findWhat = twords[j].name;

                     

                     

                    where i have forgotten to write it and in other words, i called as source.toString();

                     

                    Many thanks for you quick reply!

                     

                    You take my favourite points......

                    thanks...