5 Replies Latest reply on Jan 12, 2012 2:51 PM by Matt Finlay

    Lost in translation (AS to JS)

    Matt Finlay

      hello all,


      I have written an applescript, but i need to convert it over to JavaScript for compatibility with a 3rd party pugin.

      i am having a little trouble translating the following section of code from AS to JS.


      tell application "Adobe InDesign CS5"

               set DocumentLinks to the file path of every link of active document

      end tell


      So far i have the following in JS:


      var documentLinks = [];

      var myDocument = app.documents.item(0);


      for (var myCounter = 0; myCounter < myDocument.allGraphics.length; myCounter++){

      var myGraphic = myDocument.allGraphics[myCounter];

      var myLink = myGraphic.itemLink;

      var myPath = myLink.filePath;

      var documentLinksCount= documentLinks.push(myPath);



      When i try to run this with a specific indesign document, i get the error "null is not an object" and the "var myPath = myLink.filePath;" line is highlighted.


      I think this error is occuring because "myDocument.allGraphics.length;" has a value of 19 with this document but when i look at the links pallette manually in indesign, I only see 18 links.


      so somehow i have an image on the page that has a null path that is causing my script to error.


      can anyone tell me the best approach to bypassing this issue?