cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
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 

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

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 !

 

 

 

 

XanGregg
Staff

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] ) )
)


 

 

bobmorrane
Level V

Thanks @XanGregg , this solves my issue

Status changed to: Acknowledged

Hi @Chris_Rodrigues, thank you for your suggestion! We have captured your request and will take it under consideration.

hogi
Level XII

Most of the mentioned issues got fixed in the mean time - and with the reformatting I can live : )

What remains: comments in column formulas.

As JMP is quite open to the voice of the customer, it seems there is a strong argument against it:
comments can't stay in column formulas?
why?

hogi
Level XII

Regarding renaming of column variables in a table script, it's interesting that source scripts are edited as well.

 

In this example, by renaming the column in the summary table, the source script gets corrupted:

Names Default to Here(1);
dt = Open( "$SAMPLE_DATA/Big Class.jmp" );

dtsum = dt << Summary(
	Group( :sex ),
	Mean( :height ),
	Link to original data table( 0 )
);

dtsum:sex << Set Name( "sex_2" );



hogi
Level XII

If several users work with the same file, it could help a lot if comments were allowed in column formulas.


Using a temporary variable to store a comment string:

hogi_1-1722978671591.png

is an acceptable workaround - but comments should be visible as comments.
If possible: with well defined color -  to identify them as comments.

I just found this wish - exactly the same request:
Preserve Comments in column formulas 

in one of the replies, @mia_stephens wrote in 2023:

hogi_0-1722978518468.png

Is it still like this? For table scripts, the problem appears to have been fixed in the meantime.