11 Replies Latest reply on Jul 20, 2009 7:37 AM by Laubender

    Find tables

    jay fresno Level 1

      If there is a way to find tables by using the Find/Change dialog, I haven't been able to discover it. If there is no way to do it using Find/Change, does anyone know of a script that would find tables in an InDesign CS4 document?

        • 1. Re: Find tables
          [Jongware] Most Valuable Participant

          Sure (to both questions).

           

          In regular Find/Change, enter "<0016>" as search code. You cannot change something inside the table -- it finds and marks the entire table --, but you can use it to change the paragraph style the table resides in.

           

          If you need to do something with the table after finding it, in JavaScript you can iterate over all tables using

           

          myStory = app.selection[0].parentStory;
          for (var t=0; t<myStory.tables.length; t++)
          //  .. myStory.tables[t] now refers to a table ..
          // for example:
            myStory.tables[t].spaceBefore = "1mm";
          

           

          (where your text cursor is in the text to find tables in).

          • 2. Re: Find tables
            jay fresno Level 1

            Jongware,


            THANKS! This works great. Without your help, how would I have known that typing <0016> in the Find dialog would find tables -- Is there a special list of find commands that are not in the Find dialog?

            • 3. Re: Find tables
              [Jongware] Most Valuable Participant

              Usually, copying something from InDesign and blindy pasting it into the Find field does the trick. But it doesn't work for all objects -- XML markers, for instance, come in as "^I", but then ID is unable to find it again. I think it's the same with index markers.

               

              Another useful search is for anchored objects -- graphics or text frames pasted into running text. The code for that is "^a". I don't know where I got that from, I'm not aware of any list of 'un-common' codes.

               

              By the way, I've had comments on using <0016>, the gist of it this being a "hack" and that it might not work in later versions. Well, Adobe, in that case provide us with a valid Table shortcut. (And fix the XML search code as well, while you're at it.)

              • 4. Re: Find tables
                Peter Kahrel Adobe Community Professional & MVP

                Many unicode values can be found by selecting the character or code and displaying the Info panel: the selected character's/code's unicode value is displayed in the middle of the panel.

                 

                This doesn't always work, as is the case with tables. Then this one-liner can be used to display the selected character's value:

                 

                alert (app.selection[0].contents.charCodeAt().toString(16))

                 

                (tables are characters within stories). The only trouble is that that value could be used for other things as well, you're in the dark a bit. Tags and index markers, for instance, have the same unicode value <FEFF>.

                 

                Peter

                1 person found this helpful
                • 5. Re: Find tables
                  Laubender Adobe Community Professional & MVP

                  Jongware:

                  I can confirm that. In TEXT search I can find a table with "<0016>". Beware that you delete the table if you leave the change field blank and apply changes without specifying anything in the change format field.

                  With GREP search there is no chance to find a table (GREP search with "\x{0016}")

                  Btw. if I search for "<0018>"  both in TEXT and GREP search fields I can find the auto page number. Same behaviour for InDesign CS3 5.0.4 and CS4 6.0.3.

                   

                  You will find a collection of meta characters (InDesign CS3) with their unicode expressions at:

                   

                  http://http://www.absatzsetzer.de/downloads/Zeichen.pdf

                   

                  Uwe

                  1 person found this helpful
                  • 6. Re: Find tables
                    jay fresno Level 1

                    Laubender,

                    Thank you so much for bringing my attention to the metacharacters table. It is a wonderful reference.

                    • 7. Re: Find tables
                      jay fresno Level 1

                      Peter,

                       

                      Thank you so much for sharing your knowledge and the code for finding unicode values. I will definitely make good use of this!

                      • 8. Re: Find tables
                        Laubender Adobe Community Professional & MVP

                        Peter,

                         

                        there must be something very "strange" with "charCodeAt()". Could it be that "charCodeAt()" is restricted to a special range of characters?

                         

                        Let me elaborate: testing your line of code gave me some frustration, because at my first try the ESTK threw an error message: "app.selection[0].contents.charCodeAt is no function"

                         

                        After a bit experimenting I realized that it had to do with the testing object itself. Did I want to know the code of an ordinary character, no problem at all: the script ran smooth as expected. In case of meta characters like "AutoPageNumber" or "ColumnBrake" I had no chance: the above error message came up. I tested with InDesign CS3 (5.0.4) and CS4 (6.0.3).

                         

                        Uwe

                        • 9. Re: Find tables
                          [Jongware] Most Valuable Participant

                          It's the other way around

                           

                          InDesign determines what to return to the Javascript. In the case of regular characters, it returns a normal javascript string, which can be substr'd, concatenated, and charCodeAt'd'd'd. However, it may also return one of the SpecialCharacters enumerators, in which case the javascript type is not String, but Number -- and you cannot use 'charCodeAt'.

                           

                          You would think that forcing the returned value (string or number) to a string, using String(xx) or ""+xx (or any other method) would do something useful, but it doesn't. In the case of an AutoPageNumber, you would simply get the string "1396797550", and its charCodeAt (0) is 49 (for the "1")...

                          • 10. Re: Find tables
                            Peter Kahrel Adobe Community Professional & MVP

                            Uwe,

                             

                            That's right, that line fails on special characters. That's not because there's something strange with charCodeAt(): special characters are characters, but their contents are numbers (1396797550 in the case of autopagenumber). But they hex value of these is displayed in the Info panel. So you would first check the Info panel, and then try the one-line script. That should really be

                             

                            try {alert (app.selection[0].contents.charCodeAt().toString(16))}

                               catch (_) {alert ("Can't show Unicode value."}

                             

                            I thought I had a function to convert SpecialCharacter values to 4-digit unicode values, but can't find that.

                             

                            Peter

                             

                            Edit -- Jongware beat me to it ...

                            • 11. Re: Find tables
                              Laubender Adobe Community Professional & MVP

                              Jongware,
                              Peter

                               

                              Thank you for answering that miracle :-)

                               

                              In the meantime I did a little research at Marc Autrets superb web site in the "geek" department.

                               

                              http://http://marcautret.free.fr/geek/indd/unicode/part1.php

                               

                              My french is lousy but nevertheless I came across the following two lines of code:

                               

                              var selText = app.activeDocument.selection[0];
                              alert(selText.contents);

                               

                              In case of an meta character the number of the enummerator will show up! At least something.

                               

                              Even better:

                               

                              http://http://marcautret.free.fr/geek/indd/unicode/InDiCode.zip

                               

                              MarcAutret_InDiCode.png

                               

                              Marc states that InDiCode 1.0c is working with InDesign CS to CS3. To my joy that is true as well with InDesign CS4 (6.0.3) :-)

                              Except I minor glitch at:

                               

                              MarcAutret_InDiCode_2.png

                               

                              But you can look up the unicode value at the info palette.

                               

                              Uwe