4 Replies Latest reply on Aug 1, 2013 2:00 AM by BEGINNER_X

    Problem in Creating .txt report

    BEGINNER_X Level 3

      Hi All,

       

      I need to create the report, if the document having fpo, $$$, TK, 000 etc...

       

      OR,

       

      create report "No Errors found"

       

      My script working fine, but the problem is creating the report not as user friendly

       

      Coding is below:

       

      myDoc = app.activeDocument;
      
      FPOArray = new Array
      app.findTextPreferences = app.changeTextPreferences = NothingEnum.nothing;
      app.findChangeTextOptions.wholeWord = true
      
      app.findTextPreferences.findWhat = "fpo"
      var myFound = myDoc.findText()
      for (f = 0; f < myFound.length; f++) {
          var myFindFPOPage = myFound[f].parentTextFrames[0].parentPage.name
          FPOArray.push(myFindFPOPage)
      }
      
      $$Array = new Array
      app.findGrepPreferences = app.changeGrepPreferences = NothingEnum.nothing;
      
      app.findGrepPreferences.findWhat = "\\$\\$+"
      var myFound = myDoc.findGrep()
      for (s = 0; s < myFound.length; s++) {
          var myFind$$$Page = myFound[s].parentTextFrames[0].parentPage.name
          $$Array.push(myFind$$$Page)
      
      }
      
      var myTextFile = File("~/Desktop/abcde.txt")
      myTextFile.open("w")
      if(myFound.length>0)
      {
          myTextFile.write("FPO: " + FPOArray + "\n\n"  + "$$ Page Number: " + $$Array + "\n\n")           //Error this line only please help
          }
      else
      {
          myTextFile.write("No Error")
          }
      

       

      Could anyone please help for my request.

       

      Thanks in advance

      Beginner_X

        • 1. Re: Problem in Creating .txt report
          Mac_rk

          In both find u give myFound var so in second find if it not found than it override the myFound value and it not satified ur condition

           

          try change one var to  myFound1 and change if((myFound.length>0)  || (myFound1.length>0)) and try


          • 2. Re: Problem in Creating .txt report
            BEGINNER_X Level 3

            Hi Mac_rk,

             

            Thank you for your Tips,

             

            But still I need to tuned. Suppose in my active document having only "$$" only, but do not have FPO, TK, AU etc...

             

             

            But my report comes like as below:
              
            FPO: 
            $$ Page Number: 5
            TK:
            AU:
            
            But I need as below:
            $$ Page Number: 5                 //required output
            

             

            Is it possible. Could you help for my request.

             

            Thanks

            Beginner

            • 3. Re: Problem in Creating .txt report
              Mac_rk Level 2

              u change

               

              myTextFile.open("e") and than

               

              if(myFound.length>0)
              {
                  myTextFile.write("FPO: " + FPOArray + "\n\n" )           //Error this line only please help
                  }

               

              if(myFound1.length>0)
              {
                  myTextFile.write(
              "$$ Page Number: " + $$Array + "\n\n")           //Error this line only please help
                  }

              else
              {
                  myTextFile.write("No Error")
                  }

              • 4. Re: Problem in Creating .txt report
                BEGINNER_X Level 3

                Hi Mac_rk,

                 

                Thank you for your help...

                 

                I think recently you entered into forum and guide lot of beginners like me.

                 

                Hope you also join with the group of forum legends.

                 

                Thanks a lot again.

                 

                Beginner