cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Check out the JMP® Marketplace featured Capability Explorer add-in
Choose Language Hide Translation Bar
amurphy
Level II

Saved Log vs. Viewed Log Contain Different Content

I have a table that I've manually edited extensively and am looking to save the script for so I can automate in the future. I've written the following script (intended to be pasted into data table or allow user to run independently), which works, but I have to copy & paste into a text file to save:

 

dt = Current Data Table();

If( Is Empty ( dt ),
	Try( dt = Open(), Throw("No data table found"))
	);

Open Log();

dt << Get Script;

If I add the line Save Log (" "); it correctly saved the log, but only up to the transcript of the executed script and no longer contains the output of dt << Get Script;. I've tried many iterations of reordering the commands, but can't get the saved log to match the viewed log:

dt = Current Data Table();

If( Is Empty ( dt ),
	Try( dt = Open(), Throw("No data table found"))
	);

Open Log();

dt << Get Script;

Save Log("");

 

1 ACCEPTED SOLUTION

Accepted Solutions
Craige_Hales
Super User

Re: Saved Log vs. Viewed Log Contain Different Content

dt << Get Script;

gets the script, but doesn't do anything with it. Try

write(dt << Get Script);

JMP's behavior when evaluating an expression (even an expression with a bunch of semicolon separated statements) is to print the last result. So, when your submitted script ends with dt<<GetScript, that's what winds up in the log. Otherwise, the <<GetScript method is evaluated, the value is returned, then as soon as another statement executes, the value is thrown away in favor of the next statement's result.

 

You may need a newline in the write, something like write("\!n", dt<<GetScript). The write function adds nothing to the value that is printed, unlike the print() and show() functions.

 

Craige

View solution in original post

2 REPLIES 2
Craige_Hales
Super User

Re: Saved Log vs. Viewed Log Contain Different Content

dt << Get Script;

gets the script, but doesn't do anything with it. Try

write(dt << Get Script);

JMP's behavior when evaluating an expression (even an expression with a bunch of semicolon separated statements) is to print the last result. So, when your submitted script ends with dt<<GetScript, that's what winds up in the log. Otherwise, the <<GetScript method is evaluated, the value is returned, then as soon as another statement executes, the value is thrown away in favor of the next statement's result.

 

You may need a newline in the write, something like write("\!n", dt<<GetScript). The write function adds nothing to the value that is printed, unlike the print() and show() functions.

 

Craige
amurphy
Level II

Re: Saved Log vs. Viewed Log Contain Different Content

Thank you! That solved my immediate problem and taught me some new basics that will help a lot in the future!