5 Replies Latest reply on Feb 19, 2008 12:55 PM by (Olav_Kvern)

    IDCS3 linking in Javascript

    JADarnell Level 1
      Hello all.

      I have a very simple JS that I obtained from this forum several years ago. I recently imported it into CS3 and it errs right at the top in this line:

      b doc = app.activeDocument;

      but I don't find out about it until this line:

      b nroflinks = doc.links.length;

      where the error message "undefined is not an object" appears at the bottom of the ExtendKit window.

      The intervening lines just declare some variables. I have two questions:

      1.) Where can I find a well-explained object model since it is no longer documented in the PDF and the object model displayed in the tool kit is next to useless to figure this kind of stuff out? and

      2.) How do I get a list of links out of the document?

      Thanks for any help you can give...
        • 1. Re: IDCS3 linking in Javascript
          JADarnell Level 1
          I figured out what my problem was. I did not include the #target directive in the script. When I added it, the problem went away.

          I would still like some help on #1, however. I stand by my observation that the object model in ESTK is inadequate for learning JS for InDesign.

          R,
          John
          • 2. Re: IDCS3 linking in Javascript
            Peter Kahrel Adobe Community Professional & MVP
            Make sure that in the top left of your edit window it says "Adobe InDesign CS3". You probably see "ExtendScript Toolkit 2" there now. To avoid this in future, make a habit of including this line at the beginning of every script:

            #target indesign

            As to your two questions, (1) there isn't any; (2) depends on what you want. Press Shift+Cmd/Ctrl+D to display it on screen, or use
            >app.activeDocument.links.everyItem().name.join('\r')

            to print all link names in ESTK's console.

            Peter
            • 3. Re: IDCS3 linking in Javascript
              Peter Kahrel Adobe Community Professional & MVP
              >I stand by my observation that the object model in ESTK is inadequate for learning JS for InDesign.

              Everybody, including Adobe's engineers, would agree with that. They would also say that the object model in the ESTK is a reference, not a learning tool. For learning about the object model you need other resources. There are several scripting guides around -- see Adobe's web site.

              Peter
              • 4. Re: IDCS3 linking in Javascript
                JADarnell Level 1
                Peter:

                Thank you for your input. I appreciate it.

                R,
                John
                • 5. Re: IDCS3 linking in Javascript
                  Level 1
                  Hi John,

                  re: "I stand by my observation that the object model in ESTK is inadequate for learning JS for InDesign."

                  I agree, but I have to add: the information in the ESTK is pretty much the same as that in the earlier PDFs. Both are generated from InDesign's object model--the main difference is that we fixed errors in the source, rather than fixing them over and over again in the PDF.

                  Reference documentation is never a good way to learn about an object model--for that, you need tutorials and examples. As I've said in other posts, that's why we did away with the PDF version of the reference--so I could concentrate on the Scripting Guide.

                  For an HTML version of the reference information, see other threads about Jongware's XSLT converter (which turns the XML used by the ESTK object model viewer into a hyperlinked HTML document).

                  Thanks,

                  Ole