Announcement

Collapse
No announcement yet.

writing a file so a specific folder?

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • writing a file so a specific folder?

    I am stuck on a very simple task and have already spent too much time trying to figure it out. What do I have to add to this line - var a = new File("ES.txt"); - to get it to write in a different folder to the default eSignal\FormulaOutput folder. For example say: C:\Program Files\Test\Output?

    TIA

  • #2
    Hello theoj,

    Please review the help documentation on
    File I/O from our EFS Help Center.
    Jason K.
    Project Manager
    eSignal - an Interactive Data company

    EFS KnowledgeBase
    JavaScript for EFS Video Series
    EFS Beginner Tutorial Series
    EFS Glossary
    Custom EFS Development Policy

    New User Orientation

    Comment


    • #3
      theoj,

      I had already started this, but Jason was quicker. FWIW, I used the info in the link Jason provided to develop this in my code.

      these two lines will create a directory if it is not already there
      PHP Code:
      var f1 = new File("utility data files");//creates requisite directories if not already there
      if (!f1.exists())f1.mkDir(); 
      these commands will create a file in that directory, and append it with the date (plus another line) every time they are executed
      PHP Code:
      var file4 = new File("utility data files/date.txt");
      file4.open("at+");
      var 
      = (getYear(0))+"-"+((getMonth(0)))+"-"+(getDay(0));//note - line cannot be called until efs has started processing main
      file4.writeln(a);
      file4.writeln("hi, I am appending");
      file4.close(); 
      these commands are similar, but will overwrite the data in the file prior to writing to the file
      PHP Code:
      var file4 = new File("utility data files/date.txt");
      file4.open("wt+");
      var 
      = (getYear(0))+"-"+((getMonth(0)))+"-"+(getDay(0));//note - line cannot be called until efs has started processing main
      file4.writeln(a);
      file4.writeln("hi, I just overwrote all that info in your file");
      file4.close(); 

      Comment

      Working...
      X