0 Replies Latest reply on Jul 22, 2009 2:21 AM by Adobe-InDesign CS4

    IDCS4 - [JS] - How to find the Last paragraph with only One word - Reg.

    Adobe-InDesign CS4 Level 1

      Dear All

        Here I have a big doubt!.

            I checked Total number paragraphs in the Text Frame and Each paragraph having only 1 words and then immediatly checked with words. Its only having less than 6 characters or not, Like that I checked and throw the log file.

      But I can't add this content in the file....

       

      //================= Here my coding ===========================//

       

               var myDoc = app.activeDocument;
               var myPages = myDoc.pages;
               var myTextFrame;
               var myParagraph;
               var myParaLine;
               var myParaWord;
               var Pagecount= 1 ;
               var paraCount = 1;
               var myChars;

       

               log1 = myDoc.name.split(".indd")[0];
                  FilePath = myDoc.filePath;
                 aFile = File(FilePath + "/" + log1 + "_LastLineWords"+ ".log");
                 var today = new Date();
                 aFile.open("w");
                 aFile.seek(0,2);
                aFile.write("\n"+"  Last Line only 2 words logs       "+"\n");
                aFile.write("         - - - - - - - - - - - - - - - -               "+"\n\n");
                aFile.write("\n"+String(today+"\n"));
                aFile.close(); 

               for(var i=0; i<myPages.length; i++)
               {
                myTextFrame = myPages[i].textFrames;
                 for(var j=0; j<myTextFrame.length; j++)
                  {
                    myParagraph = myTextFrame[j].paragraphs;
                   for(var k=0; k<myParagraph.length; k++)
                    {
                      if(myParagraph.length >= 2)
                   {
                      myParaLine = myParagraph[k].lines;
                    for(var m=0; m<myParaLine.length; m++)
                     {
                       if(myParaLine[m].words.length < 2 )
                        {
                         myChars = myParaLine[m].words;
                       for(var n=0; n<myChars.length; n++)
                        {
                         if (myChars[n].characters.length < 6 )
                         {
                          aFile.open("e");
                          aFile.seek(0,2);
                         
                          app.select(myChars[n])
                          var mySel = app.selection[0];
                          $.writeln(mySel.contents);
                          $.writeln(mySel);
                          aFile.write("\n"+"Contents :"+"\t"+mySel.contents+"\n");
                          aFile.write("\n"+"Line No. of the Content  :"+"\t"+ myParaLine.length+"\n");
                          aFile.write("\n"+"Pargraph No. of the Content  :"+"\t"+ paraCount+"\n");
                          aFile.write("\n"+"Page No. of the Content   :"+"\t"+ Pagecount+"\n");
                          aFile.close();
                        }
                       }
                         }
                       }
                     paraCount +=1;
                    }
                     }
                   }
                 Pagecount +=1;
                }
         //======================================== Execute the Log File =================================//
                  if(aFile.length != 0)
                 {
                  aFile.execute();
                  }
                   else
                 {
                   var myDelFile = File(FilePath + "/" + log1 + "_LastLineWords"+ ".log");
                   myDelFile.remove();
                     exit(0);
                  }


      //========================== End of the Script =======================================================//

       

      The $.writeln(mySel); throws [Object Text]... How to write the contents in my Log file.

       

      This is working in non-xml contents but this is not working in xml contents. Please anybody can check the above code and please give me the suggestion....

       

      Please any one can help me, I will appreciate....

       

       

      Thanks & Regards

      T.R.Harihara Sudhan