2 Replies Latest reply on Mar 27, 2012 10:17 AM by KuddRoww

    Writing an array to a text file. (Save the children.)

    KuddRoww Level 1

      I'm trying to break an InDesign file down into its sentences and export it into a text file. When I created a prompt with the contents of newArr.join("\r") everything looks exactly as I'd like it to, the sun is shining and the children are merry. However when I try to write the array to a text file it appears as if nothing happens, the sun hides and the children are miserable.

       

      How can I make the children happy again and write the array to the text file?

       

      Thank-you for any and all help!

       

       

      #target indesign

      myDoc=app.activeDocument; // in file

      reportFile = File("c://users//kudrow//desktop//reportFile.txt"); // out file

      newArr = [];

      //Target textframes in file, split textframes, push textframes onto array

      for(i=0; i<myDoc.pages.count(); i++){

              for(j=0; j<myDoc.pages[i].textFrames.count(); j++){

                  myFrame = myDoc.pages[i].textFrames[j].contents;

                  newFrame = myFrame.split(/\r|\n|\./)

              for(k=0; <newFrame.length; k++){

                  newArr.push(newFrame[k]);

              }

          }

      }

      //write array to text file

      reportFile.open('w');

      reportFile.write(newArr.join("\r"));

      reportFile.close();

         

       

       

      Message was edited by: KuddRoww