Choose Language Hide Translation Bar

Preserve comments and whitespace in JSL code attached to data table

When I write code, I try to make it easy to read, understand, and maintain.  I write comments.  I indent code blocks.  I use line breaks to spread the code out over multiple lines.  I try to write code with a consistent style.  However, I frequently find that JMP reformats my code without asking.  It simply decides to obliterate all the effort that I put into good coding practices.


For example, I write a script and attach it to a data table.  Then I right-click on the script and press "Copy" and then right-click in the script window and press "Paste".  The copy of the script does not contain any of the comments or code block indentions that were in the original script.


Another example:  I create a formula column on a data table.  Inside of the formula editor block, I write some JSL code to perform an iterative calculation (this is really cool. I just figured out you could do this!).  Of course I want to use comments and whitespace in this code, like I would in literally any code that I write anywhere.  Well, after I hit enter, the comments are invisible until I double-click on the formula editor block.  But they do exist.  Until I click OK and JMP evaluates the formula.  Next time I open the formula, comments and whitespace are gone.


It gets worse.  I have multiple scripts attached to my table that all reference a certain column.  Then I rename that column.  All of these scripts are updated with the new column name.  But in doing so, they are all "reformatted" by the JSL parser and all of my comments and whitespace are destroyed.  ಠ_ಠ


What is the point of even having comments in the JSL language if JMP is going to immediately wipe them out at the first opportunity?  Am I supposed to edit my JSL scripts in a less-hostile text editor (i.e. Notepad++) and store the readable versions as separate files?  I just don't understand why it has to be this way.  Please leave my comments alone!


Note: @Cwalla reported the same issue in the forums here 

Tracking Number:

Defect ID: S1558810

Level IV
I do store well-formatted versions of scripts as text file separately. I hope JMP preserves the format.
Level IV

Hi @Chris_Rodrigues,



I was just having a discussion on this topic:  How-to-keep-formatting-and-comments-with-New-Script  

My issue does not arise in exactly the same context but the result is the same: when a script add a new script to a data table using the New Script () function, comments and layout are lost.


I thought there might be a workaround but to re-insert comments and layout in script within data tables but it looks like this is not the case.

While we wait for your wishlist item to be approved, there are a couple of solutions that one could use :

-Store your scripts in separate files. In your data table, your scripts would just be a link to open the .jsl files. Like this there would be no chance of losing information.

-Store your comments in a custom made comment function that just writes your comments in the log. I know it's not ideal, since you could still lose your layout but at least your comments would be preserved.


Let's hope more people Kudo this wish, it looks very necesary !






I added a JSL Quote example to the thread.


New Table( "formatted script",
	New Script( "my script",
		Eval( Parse(JSL Quote(
// example
x = 1;

		Print( :column 1[1], y );
)			)
	New Column( "Column 1", Set Values( [5] ) )



Level IV

Thanks @XanGregg , this solves my issue