3 Replies Latest reply on Mar 21, 2014 12:39 PM by pixxxel schubser

    How do I create an array with variables also splits words  in a txtfile?

    Dapeamel Level 1

      Hello guys,

       

      I made a script that reads a text file.

       

       

      function readMyFile()

      {

      var myFile=File(app.activeDocument.filePath + "/LareLog.txt");

      if (myFile.exists)

              {

              myFile.open("r");

              var Temps =  myFile.read();

              alert (Temps);                          // message the content

              var nyRad=("\n");                    // break the line

              textArr=Temps.split(nyRad);

              alert(textArr);                          // message the content with all info on new lines ("\n");

              myFile.close();

              }

      }

       

      my textfile contains:


      ~/Desktop/3.indd ,Thu Mar 20, 2014, 11:26:34 , GMT+0100

       

       

       

      I wonder how do I sort the content in array

      in this order, also creates variables for each string.

      var= string 1[~/Desktop/3.indd]

      var2=string 2[11:26:34]

      var3=string 3[11:26:34]

      var4=string 4[2014]

      var5=string 5 [GMT+0100]

       

       

      Thank you in advance people.