3 Replies Latest reply on Apr 26, 2016 3:28 AM by Peter Kahrel

    Need help with a line in CS3 scripting

    runew73276507 Level 1

      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[i].status == LinkStatus.LINK_MISSING || myLinks[i].status == LinkStatus.LINK_OUT_OF_DATE && myLinks[i].parent.parent.itemLayer.visible== true){  
      
      
        try{
      
        thePageName = myLinks[i].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[j].overflows && myFrames[j].itemLayer.visible == true){  
        
             try { 
        
               thePageName = myFrames[j].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();
        
         } 
      }