cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
  • New to JMP? Join us Sept. 23-24 for the Early User Edition of Discovery Summit, tailor-made for new users. Register now for free!
  • Use World Cup data to build models, explore spatial relationships, and create informative visualizations in JMP. Register. July 17, 2 pm US Eastern Time.
  • Your voice matters! Tell us how you prefer to receive JMP updates, so we can tailor our communication to your needs. Take short survey.

Discussions

Solve problems, and share tips and tricks with other JMP users.
Choose Language Hide Translation Bar
ravi_sasjmp
Level II

Save Log Window To File, Append If File Exists

Is there a way in JSL to save contents of log window to a file and if the file exists, append to it rather than overwrite it

Save Log("$myroot/Log_File.txt");
1 ACCEPTED SOLUTION

Accepted Solutions
Craige_Hales
Super User

Re: Save Log Window To File, Append If File Exists

Yes. Here's the heart of the answer:

Save Text File( "$desktop/log.txt", 
    Concat Items( Get Log(), "\!N" ), 
    Mode( If( File Exists("$desktop/log.txt"), "append", "replace" ) ) )

As shown, it adds some unwanted text to the log, and may not add some text you do want. If you make it an add-in, nothing is added to the log.

You might want a separator, or a date. You could concatenate those to the Concat Items() result.

You might want a file name prompt; you can add that as well.

Edit: And it might make sense to Clear Log() if you plan to do multiple appends in one session. 

Craige

View solution in original post

1 REPLY 1
Craige_Hales
Super User

Re: Save Log Window To File, Append If File Exists

Yes. Here's the heart of the answer:

Save Text File( "$desktop/log.txt", 
    Concat Items( Get Log(), "\!N" ), 
    Mode( If( File Exists("$desktop/log.txt"), "append", "replace" ) ) )

As shown, it adds some unwanted text to the log, and may not add some text you do want. If you make it an add-in, nothing is added to the log.

You might want a separator, or a date. You could concatenate those to the Concat Items() result.

You might want a file name prompt; you can add that as well.

Edit: And it might make sense to Clear Log() if you plan to do multiple appends in one session. 

Craige

Recommended Articles