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
bobmorrane
Level V

How to keep formatting and comments with New Script () ?

Hello everyone,

 

it's me again. Another day, another question

So I made a nice long script that creates a new data table which contains some scripts. I use the New Script () function to do this.

dt<< New script ("myscript",

// comments
//beautiful indentation
   (
       (
        (  (  instructions) )
         )
      )
 ) 

);

 

My issue is that when I check the script Inside the table dt, all comments are lost, as well as the layout, my personal style of indentation, empty lines, etc.

These scripts are intended for users who are not necesarily familiar with JSL, so I need to keep the comments and the original layout.

 

I was trying to do something like putting my scripts in a string and using Append() or Append Text() but was unsuccessful.

 

mystring = " \[ // all my
                    // script
                       ]\" ;

myscript = dt<<New Script ("my script",
//some instructions
);
myscript  << Append Text (mystring)

Unfortunately this did not work. Any ideas ? Some tricks using Expr/ Eval , etc maybe ?

 

 

 

~~Bob~~
11 REPLIES 11
XanGregg
Staff

Re: How to keep formatting and comments with New Script () ?

JSL Quote() might help:

 

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

Re: How to keep formatting and comments with New Script () ?

well, well, well, it looks like we have a winner !

 

I love it when you spend days grinding your gears on a seemingly impossible problem and then someone reveals the solution to be a one line script

 

thanks a lot @XanGregg 

 

 

 

~~Bob~~