10 Replies Latest reply on Mar 3, 2009 7:00 PM by dhishok

    Give #10 increment to each index entry folios....

    dhishok Level 1
      Hi experts,

      Already we finished the index file in InDesign CS2. Now the file is in the correction stage. The corrections is to update each entries folios by adding ten numbers.

      Example:

      A-B-C model of emotional reactions, 592593
      ability, 392
      abnormal behaviour, 602604.
      absolute, 82
      accommodation, 136, 474475
      acculturation, 335

      It is too hectic to do manually, can anyone help me for this.

      Thanks in advance
      Thiyagu
        • 1. Re: Give #10 increment to each index entry folios....
          Level 1
          Does this work?
          myIndex = app.selection[0].parentStory
          
          setupFindGrep("\\d+")
          myFinds = myIndex.findGrep();
          for (var j = myFinds.length - 1; j >= 0; j--) {
            myFinds[j].contents = String(Number(myFinds[j].contents) + 10)
          }

          function setupFindGrep(find, change, foots, hidLayers, lockedLayers, lockedStories, masters) {
            app.findGrepPreferences = null;
            app.changeGrepPreferences = null;
            try { app.findGrepPreferences.findWhat = find } catch(e) {};
            try {app.changeGrepPreferences.changeTo = change } catch(e) {};
            app.findChangeGrepOptions.properties = {
              includeFootnotes:(foots == null ? false : foots),
              includeHiddenLayers:(hidLayers == null ? false : hidLayers),
              includeLockedLayersForFind:(lockedLayers == null ? false : lockedLayers),
              includeLockedStoriesForFind:(lockedStories == null ? false : lockedStories),
              includeMasterPages:(masters == null ? false : masters)
            }
          } // end setupFindGrep
          Be warned that I just wrote this here and haven't tested it. The function works correctly; that I lifted from my library of text snippets.

          Dave
          • 2. Re: Give #10 increment to each index entry folios....
            Level 1
            Of course, this approach assumes that there are no digits in any of the index topic names.

            Dave
            • 3. Re: Give #10 increment to each index entry folios....
              dhishok Level 1
              Hi Dave,

              Great its working fine with CS3. Thanks for your kind support. Sorry dave, last two days unfortunately i was out of station. We need this script for InDesign CS2 because the source file is in CS2. Once again i am thanking you.

              Regards
              Thiyagu
              • 4. Re: Give #10 increment to each index entry folios....
                Level 1
                Export the index to RTF, pour it into CS3, run the script, export again as RTF, run it back into the CS2 document.

                Dave
                • 5. Re: Give #10 increment to each index entry folios....
                  dhishok Level 1
                  Hi Dave,

                  Thanks for your valuable support. I am also felt the same. I know its very difficult to do in CS2. But i am just asking you that there is any way to do this in CS2. Once again Thanks dave.

                  Thiyagu
                  • 6. Re: Give #10 increment to each index entry folios....
                    Level 1
                    It can be done but it is quite an effort. If I were faced with the problem I'd write a script, but I stopped using CS2 a long time ago.

                    Dave
                    • 7. Re: Give #10 increment to each index entry folios....
                      dhishok Level 1
                      Ok thanks Dave.

                      Thiyagu
                      • 8. Re: Give #10 increment to each index entry folios....
                        dhishok Level 1
                        Hi Dave,

                        I have done some modifications in the script according to our requirement with your script. Its working fine. I need help from you regarding searches between the range of numbers. For example in index i need to add numbers between the range 250 and 450. So the script has only find & add numbers, if the page numbers greater than 250 and Less than 450. Find the modified script below.

                        //To regenerate the Index numbers...

                        try
                        {
                        myIndex = app.selection[0].parentStory
                        }
                        catch(e)
                        {
                        alert ("Sorry! Place the cursor into the Story and then Try...")
                        exit();
                        }

                        //TO FIND ONLY BEGINING OF NUMBERS

                        setupFindGrep("\\<\\d+")

                        myFinds = myIndex.findGrep();
                        myVariable = prompt('Please the Enter Value: E.g. (2 or -2, 10 or -10)', '');

                        for (var j = myFinds.length - 1; j >= 0; j--) {
                        myFinds[j].contents = String(Number(myFinds[j].contents) + Number(myVariable))
                        }
                        function setupFindGrep(find, change, foots, hidLayers, lockedLayers, lockedStories, masters) {
                        app.findGrepPreferences = null;
                        app.changeGrepPreferences = null;
                        try { app.findGrepPreferences.findWhat = find } catch(e) {};
                        try {app.changeGrepPreferences.changeTo = change } catch(e) {};
                        app.findChangeGrepOptions.properties = {
                        includeFootnotes:(foots == null ? false : foots),
                        includeHiddenLayers:(hidLayers == null ? false : hidLayers),
                        includeLockedLayersForFind:(lockedLayers == null ? false : lockedLayers),
                        includeLockedStoriesForFind:(lockedStories == null ? false : lockedStories),
                        includeMasterPages:(masters == null ? false : masters)
                        }
                        } // end setupFindGrep
                        alert ("The Index has been Updated with (" + myVariable + ") Numbers...")

                        //End of sript

                        Can you please look into this and help me. Thanks in advance Dave.

                        Regards
                        Thiyagu
                        • 9. Re: Give #10 increment to each index entry folios....
                          [Jongware] Most Valuable Participant
                          This

                          >myFinds[j].contents = String(Number(myFinds[j].contents) [..]

                          is the place where the 'found' number is evaluated.
                          Have you tried

                          a = Number(myFinds[j].contents);
                          
                          if (a > 250 && a < 450)
                          ...
                          ? Should work just fine.
                          • 10. Re: Give #10 increment to each index entry folios....
                            dhishok Level 1
                            Hi jongware,

                            Thanks for your valuable support. Last one week i was not feeling well. That is why this much late reply. I have tried your syntax it is working fine. Thanks lot my scripting guru.

                            Regards
                            Thiyagu