Skip to main content
runew73276507
Known Participant
April 25, 2016
Question

Need help with a line in CS3 scripting

  • April 25, 2016
  • 1 reply
  • 470 views

Hi all scripters,

I have this script for InDesign CS3:

if (app.documents.length != 0){

   var MY_DOC = app.activeDocument;

   var myLinks = MY_DOC.links; 

 

   var thePageNames = new Array();

  

   for (var i = 0 ; i <= (myLinks.length - 1); i++){

   

     if(myLinks.status == LinkStatus.LINK_MISSING || myLinks.status == LinkStatus.LINK_OUT_OF_DATE && myLinks.parent.parent.itemLayer.visible== true){ 

  try{

  thePageName = myLinks.parent.documentOffset;

  } catch (e) {

   

            continue; // must be on Pasteboard so ignore

       }  

  

        thePageNames[thePageName] = 0

     }  

   }   

     if (thePageNames.length == 0) {  

  

  } else{  

   

        var s = "";

     for (i in thePageNames){

  

       s = s + app.documents[0].pages[Number(i) - 1].name + ", ";

   

    }   

       

  s = s.substring(0,s.length - 2);   

      

  if(!confirm("Missing or not updated links in document - continue?"))

            exit();  

   

   }

}

When I run it nothing happens BUT if i change to this in line 28:

     if (thePageNames.length !== 0)

{  

and run the script again I get the confirm text from line 43 all the time even thoe there is no links in the document - what am I missing?

It works perfectly when I run this almost similar script for the overset text:

if (app.documents.length != 0){ 

 

   var myFrames = app.activeDocument.textFrames; 

 

   var thePageNames = new Array(); 

 

   for (var j = 0 ; j <= (myFrames.length - 1); j++) { 

 

     if(myFrames.overflows && myFrames.itemLayer.visible == true){ 

 

       try {

 

         thePageName = myFrames.parent.documentOffset;

 

       } catch (e) { 

 

         continue; // must be on Pasteboard so ignore

 

       }

 

       thePageNames[thePageName] = 1 

 

     } 

 

   } 

   if (thePageNames.length == 0) {  

  

  

   } else{  

       var s = ""; 

 

     for (i in thePageNames) {  

 

       s = s + app.documents[0].pages[Number(i) - 1].name + ", "; 

 

     } 

 

     s = s.substring(0,s.length - 2); 

 

     if(!confirm("overset text inside the document frame - continue?"))

     exit();

 

   }

}

This topic has been closed for replies.

1 reply

Peter Kahrel
Community Expert
Community Expert
April 25, 2016

myLinks.parent returns the image

myLinks.parent.parent returns the image's containing rectangle

myLinks.parent.parent.parent returns the rectangle's parent. That's a spread in CC, not sure about CS3.

Peter

runew73276507
Known Participant
April 26, 2016

Hi Pkahrel,

Thank you for your answer but I am not sure where to put your lines into the script? I know that parent.parent is no good for CS3

Peter Kahrel
Community Expert
Community Expert
April 26, 2016

Line 15 in your script:

thePageName = myLinks.parent.documentOffset

myLinks.parent is an image, and images don't have a documentOffset property.

> I know that parent.parent is no good for CS3

How do you know that? Did you test that, e.g. with the following script?

$.writeln (app.documents[0].links[0].parent.constructor name);

$.writeln (app.documents[0].links[0].parent.parent.constructor name);

$.writeln (app.documents[0].links[0].parent.parent.parent.constructor name);

Open your document and run the script in the ESTK.

P.