10 Replies Latest reply on Feb 19, 2008 1:11 PM by Jukka Lauhalahti

    [AS][CS3] How to make index in CS3

    Jukka Lauhalahti
      Hi!

      Can't find any references how to create index with AppleScript.
      I have a list of words that i can search but how to make them an index entry?

      Any help appreciated.

      jukka
        • 1. Re: [AS][CS3] How to make index in CS3
          Martin Fischer Level 2
          Hi Jukka,

          you have to make topics with page references.

          Take a look at Peter Kahrels JS in Peter Kahrel, "generating an index from all instances of a particular character style" #3, 18 Oct 2007 8:47 am

          Or inspect IndexFromList.jsx in http://www.hilfdirselbst.ch/foren/Skript_zum_Index_generieren_P279797.html#279797

          You might translate the JS into AppleScript.

          Martin
          • 2. Re: [AS][CS3] How to make index in CS3
            Jukka Lauhalahti Level 1
            Thanks Martin!

            Sorry to but my JS skills are limited. I basically understand it but coverting to AS is big problem.

            Olivier Berquin has a script for CS1 but it doesnt work with CS3.

            Where to look for how to change CS1-2 scripts to CS3?
            • 3. Re: [AS][CS3] How to make index in CS3
              Martin Fischer Level 2
              Jukka,

              instead of converting it to AS you also can use the JS as it is - even with InDesign CS3 for Mac. ;-)

              My suggestion to the JS-solution should show you which of the objects should have to be adressed and treated in which way. You should get an imagination of how to set up the making of index entries.

              For the JS works very fine for me I don't have any need to translate it into AS.

              But maybe you can - after studying the JS?

              What is the code of Olivier Berquin and what are the error messages in CS3?

              Martin
              • 4. Re: [AS][CS3] How to make index in CS3
                Jukka Lauhalahti Level 1
                http://olivier.berquin.free.fr/indesign/indesign_cs1.html#top_index_From_Char_Style

                I've made many scripts with CS2 but where to find what has changed in CS3?

                Adobe's guide does not even mention creating index...
                • 5. Re: [AS][CS3] How to make index in CS3
                  Martin Fischer Level 2
                  Jukka,

                  > but where to find what has changed in CS3?

                  The main changes in CS3 you will have to keep in mind developing your AS to make index entries belong to the find-search engine.
                  You will find some examples in the AS sample files delivered with InDesign CS3.

                  Further on you can study the discussion about changes in CS3 in http://www.adobeforums.com/webx/.3bc3cc98/48

                  At least I have noticed that the link above to the JS is a link to a CS2-version of the JavaScript.
                  Here is the link to the CS3-version: http://www.hilfdirselbst.ch/foren/Skript_zum_Index_generieren_P322824.html#322824

                  Martin
                  • 6. Re: [AS][CS3] How to make index in CS3
                    Jukka Lauhalahti Level 1
                    Martin,

                    wrote:
                    You will find some examples in the AS sample files delivered with InDesign CS3.

                    My search of the expales in CS3 DVD:s did not find any reference how to create indexes in CS3, also downloaded all examples i could find from Adobe and no luck. Perhaps i'm not that good finding things...
                    ;-)

                    Well, must try to convert the JS examples you kindly gave.
                    Maybe i should start learning JS.

                    Thanks.
                    • 7. Re: [AS][CS3] How to make index in CS3
                      Martin Fischer Level 2
                      Jukka,

                      > My search of the expales in CS3 DVD:s did not find any reference how to create indexes in CS3,

                      I have meant that you will find some examples to customice the search code in Olivier's CS2-AS for CS3.

                      e.g. change

                      > set find preferences to nothing

                      to

                      > set find text preferences to nothing

                      Customizing the settings relating to find-change will be the most of the job.

                      I cannot remember things related to index that have changed in CS3 since CS2. But things related to find-change have changed in CS3!

                      So you have find out, which of Oliviers code lines should be customized that find-change will work in CS3 too.

                      Or do you want to hire somebody to do this job for you?

                      Martin
                      • 8. Re: [AS][CS3] How to make index in CS3
                        Jukka Lauhalahti Level 1
                        I've allready survived the "find-change" changes, as wrote my initial post, i have a text list with names that i can search in CS3 (and attach a characterStyle etc) but i don't find any help for making index entrys with AS. Did search all my CS2 material too but no luck.

                        Oliviers example is for CS1.

                        Anyway, thanks all the help!

                        jukka

                        PS.
                        Any good books on JS with CS3?
                        • 9. Re: [AS][CS3] How to make index in CS3
                          Martin Fischer Level 2
                          Hi Jukka,

                          I have inspected the AS of Olivier and have done some changes.
                          Here is the version for CS3 fo Olivier's script.
                          Hope you can learn to understand some changes by comparing the CS-version (comments in brackets: -- [CS] ...) with the CS3-version.

                          Most of the changes had to do with the setup of the find preferences, as expected.
                          One change you can see in the setting up of the index topic:
                          CS: set myPageReference to make page reference with properties {parent story:myStory, story offset:index of myFoundItem}
                          CS3: set myPageReference to make page reference with properties {source text:myFoundItem}

                          That's all:
                          <pre>
                          -- [CS] tell application "InDesign CS"
                          tell application "Adobe InDesign CS3"
                          -- [CS] set find preferences to nothing
                          set find text preferences to nothing
                          -- [CS] set change preferences to nothing
                          set change text preferences to nothing

                          set myDocument to active document

                          tell myDocument
                          set myIndex to make index
                          end tell

                          tell myDocument
                          set EveryCharacterStyle to every character style
                          set NameOfEveryCharacterStyle to name of every character style

                          set myIndex to make index
                          end tell

                          set ChooseStyle to choose from list NameOfEveryCharacterStyle with prompt "Choose one (or more) character style(s)" with multiple selections allowed

                          if ChooseStyle is not false then
                          -- Search for the correspondance of Name of char style and object reference of it
                          set ListOfCharStyleToIndex to {}
                          tell myDocument
                          repeat with i from 1 to count of ChooseStyle
                          set end of ListOfCharStyleToIndex to character style (item i of ChooseStyle)
                          end repeat
                          end tell

                          -- Search for every occurence of text with the first applied character style in ListOfCharStyleToIndex
                          set SearchStyle to item 1 of ListOfCharStyleToIndex
                          -- [CS] set FoundObjects to (search myDocument with find attributes {applied character style:SearchStyle})
                          set applied character style of find text preferences to SearchStyle -- new in [CS3]
                          set FoundObjects to find text of myDocument
                          -- When multiple selections
                          repeat with j from 2 to count of ListOfCharStyleToIndex
                          set SearchStyle to item j of ListOfCharStyleToIndex
                          -- [CS] set FoundObjects to FoundObjects & (search myDocument with find attributes {applied character style:SearchStyle})
                          set applied character style of find text preferences to SearchStyle -- new in [CS3]
                          set FoundObjects to FoundObjects & (find text of myDocument)
                          end repeat

                          -- Loop (reverse)
                          repeat with i from (count FoundObjects) to 1 by -1
                          tell myIndex
                          -- Add the topic to the index if it does not already exist.
                          try
                          set myTopicName to contents of item i of FoundObjects
                          set myTopic to topic myTopicName of myIndex
                          on error
                          set myTopic to make topic with data {name:myTopicName}
                          end try
                          end tell
                          set myFoundItem to object reference of item i of FoundObjects
                          set myStory to parent story of myFoundItem
                          -- Create the page reference.
                          tell myTopic
                          -- [CS] set myPageReference to make page reference with properties {parent story:myStory, story offset:index of myFoundItem}
                          set myPageReference to make page reference with properties {source text:myFoundItem}
                          end tell
                          end repeat
                          display dialog "Done!" buttons "OK" default button 1 giving up after 2
                          end if

                          -- [CS] set find preferences to nothing
                          set find text preferences to nothing
                          -- [CS] set change preferences to nothing

                          end tell
                          </pre>

                          Martin
                          • 10. Re: [AS][CS3] How to make index in CS3
                            Jukka Lauhalahti Level 1
                            Martin, youre Beast!

                            The find-change part i figured out but it was the line:
                            set myPageReference to make page reference with properties {source text:myFoundItem}

                            that i couldnt figure out.

                            I was fiddling with the JS script "Skript zum Index generieren" and had to change it a little bit to suit my purposes (split-concate stuff). Maybe i turn into JS...

                            Just did some alterations to do the index in reverse order (lastname first name). Works like a charm.

                            Once again thanks a LOT!

                            jukka