8 Replies Latest reply on Dec 4, 2008 9:42 AM by (WillAdams)

    [AS-CS3] How to create subtopics in an index?

    Level 1
      I wrote a script whose make an index from character styles.
      I guy ask to me:
      "We've just had a print customer ask us for help w/ their index --- I've got it worked out except for adding sub-topics, sub-sub-topics and (of course) sub-sub-sub-topics."

      I don't write scripts for a long time (due to my work).
      Is it possible to make that???

      I thing the short answer is "no", but...

      Thanks.

      Oli.
        • 1. Re: [AS-CS3] How to create subtopics in an index?
          Level 1
          You can certainly make such topics from a script, but how does the script know which is a sub-topic of what?

          Dave
          • 2. Re: [AS-CS3] How to create subtopics in an index?
            Level 1
            The script in question knows how many levels there are (stored in the variable ``howMany'') and has the index terms in indexone through indexfour --- all I need is the more complicated versions of:

            tell myIndex
            -- Add the topic to the index if it does not already exist.
            try
            set myTopic to topic indexone of myIndex
            on error
            set myTopic to make topic with data {name:indexone}
            end try
            end tell
            tell myTopic
            make page reference with properties {parent story:myStory, source text:myFoundItem}
            end tell
            end if

            where set myTopic adds indexone (as a level1 topic) _and_ indextwo as a sub-topic to indexone and then makes a page reference, &c. (for sub-sub-topics and sub-sub-sub-topics, indexthree and indexfour respectively).

            William
            • 3. Re: [AS-CS3] How to create subtopics in an index?
              Level 1
              Hi William,

              Funny to see here!
              Like Dave said, I "must" to know the topic of the word...
              I "must" to know that "setter" is a dog, and not a cat...

              Maybe we can try to make -- for each word searching from a character style --, a dialog with "wich level?", and an other one with every words of this level.

              So, in my opinion, it's more simple to make this in Indesign without script... This is the same works for the user...

              Oli.
              • 4. Re: [AS-CS3] How to create subtopics in an index?
                Level 1
                If it was just one or two or a dozen index entries or so, but there are thousands of entries.

                If one has the selected text in MyFoundItem, and has parsed it to:

                main topic == indexone
                how many index entries there are == howMany
                sub-topic == indextwo
                sub-sub-topic == indexthree
                sub-sub-sub-topic == indexfour

                Surely one can then add a topic and a page reference using AppleScript. If not, why not?

                William
                • 5. Re: [AS-CS3] How to create subtopics in an index?
                  Level 1
                  Here's a message I'm about to post to the applescript-list (my apologies for those who're seeing it twice):

                  I'm trying to up-date Olivier Berquin's script (located somewhere near here):

                  http://olivier.berquin.free.fr/indesign/indesign_cs1.html

                  so that it will make multi-level indexes.

                  I'm currently working in CS2 (but I don't think the indexing code has changed much since then), and have managed to get to the point where I have:

                  FoundObjects -- a list of all the things which need to be indexed
                  myFoundItem --- the thing which I want to index
                  howMany --- the number of index levels (1, 2, 3, or 4)
                  indexone --- the main topic
                  indextwo --- the sub-topic (if any)
                  indexthree --- the sub-sub-topic (if any)
                  indexfour --- the sub-sub-sub-topic (if any)

                  Olivier's script has:

                  tell myIndex
                  -- Add the topic to the index if it does not already exist.
                  try
                  set myTopic to topic indexone of myIndex
                  on error
                  set myTopic to make topic with data {name:indexone}
                  end try
                  end tell
                  tell myTopic
                  make page reference with properties {parent story:myStory, source text:myFoundItem}
                  end tell

                  (which I have wrapped up in an if howMany is 1 then .... endif block)

                  to check and see if an index entry exists and make it if it doesn't, but I'm simply not understanding how one would code adding a sub-topic, sub-sub-topic or sub-sub-sub-topic and the page reference to the last topic --- I just need to fill in the last three code blocks (if howMany is 2, 3 or 4 then ... endif) --- how do I do that?

                  William
                  • 6. Re: [AS-CS3] How to create subtopics in an index?
                    Level 1
                    Hi William,

                    My apologize if I make a mistake about your question...
                    To enter a sub-topic, you MUST have the name of the topic.
                    For example, I want to "index" the word "bicyle" into the topic "transportation". In InDesign, it's very simple, I know that the bicycle is a way of transportation. "I" know that.

                    Now, thing about Applescript.
                    How the machine knows that the bicycle is a way of transportation, and not a system of cooking?

                    I've right? (don't know, in english, if it is "I've right" or "I'm right"???)

                    Oli.
                    • 7. Re: [AS-CS3] How to create subtopics in an index?
                      Level 1
                      In English one would more likely pose it as a question, ``Am I right?'' If you wanted to make the statement it would be ``I'm right.'' (not sure why the order flops between the forms though).

                      The indexing data has all of that.

                      It has transportation in indexone and bicycle in indextwo (and howMany is 2 and myFoundItems contains the text:

                      transportation
                      bicycle

                      so that one knows where the page reference goes.

                      All that I need is the code that handles there being 2, 3 or 4 levels, e.g.:

                      if howMany is 2 then
                      tell myIndex
                      -- Add the topic to the index if it does not already exist.
                      try
                      set myTopic to topic indexone of myIndex
                      on error
                      set myTopic to make topic with data {name:indexone}
                      end try
                      try
                      tell topic indexone of myTopic
                      set myTopic to topic indextwo of myIndex
                      end tell
                      on error
                      tell topic indexone of myTopic
                      set myTopic to make topic with data {name:indextwo}
                      end tell
                      end try
                      end tell
                      tell myTopic
                      make page reference with properties {parent story:myStory, source text:myFoundItem}
                      end tell
                      end if

                      (but that doesn't work and I can't see why it doesn't).

                      Please believe me that the InDesign document will be fully populated w/ thousands of index entries as text formatted however I specify --- all I need is a script which finds them and inserts the multi-level index topics and page references.

                      William
                      • 8. Re: [AS-CS3] How to create subtopics in an index?
                        Level 1
                        I finally figured out the magic incantation --- you have to add the topic to a topic.

                        Thanks!

                        William