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
lwx228
Level VIII

How to use JSL to write a script in the specified JMP file and save it in the JMP?

Such as:Abrasion.jmp

dt = Open( "$SAMPLE_DATA/Abrasion.jmp" );
dt << Select Where( Shift == "A" );
d3 = dt << Subset( Output Table( "ts" ), Selected Rows( 1 ), selected columns( 0 ) );

JSL extracts A subset of file "Abrasion.jmp" and creates A script in this subset file that writes the following:

d3 = Current Data Table();
d3 << Sort( By( 6 ), Order( Descending ), replace table );

2021-10-18_213322.png

Thanks Experts!

1 ACCEPTED SOLUTION

Accepted Solutions
txnelson
Super User

Re: How to use JSL to write a script in the specified JMP file and save it in the JMP?

Here is one way to handle this

Names Default To Here( 1 );
dt = Current Data Table();
Eval(
	Parse(
		"dt<<new script(\!"test\!",d3 = Current Data Table();
d3 << Sort( By( 6 ), Order( Descending ), replace table );"
	)
);
Jim

View solution in original post

4 REPLIES 4
txnelson
Super User

Re: How to use JSL to write a script in the specified JMP file and save it in the JMP?

Here is one way to handle this

Names Default To Here( 1 );
dt = Current Data Table();
Eval(
	Parse(
		"dt<<new script(\!"test\!",d3 = Current Data Table();
d3 << Sort( By( 6 ), Order( Descending ), replace table );"
	)
);
Jim
lwx228
Level VIII

Re: How to use JSL to write a script in the specified JMP file and save it in the JMP?

Thank Jim!
lwx228
Level VIII

Re: How to use JSL to write a script in the specified JMP file and save it in the JMP?

This JSL can write a script with the specified content to a newly generated JMP file.
But here the original JSL seems to have stopped automatically without executing the following code.

dt = Open( "$SAMPLE_DATA/Abrasion.jmp" );
dt << Select Where( Shift == "A" );
d3 = dt << Subset( Output Table( "ts" ), Selected Rows( 1 ), selected columns( 0 ) );
Eval(
	Parse(
		"d3<<new script(\!"test\!",d3 = Current Data Table();
d3 << Sort( By( 6 ), Order( Descending ), replace table );"
	)
);
d3<<setName("new");

Thanks Experts!

2021-10-19_115657.png

txnelson
Super User

Re: How to use JSL to write a script in the specified JMP file and save it in the JMP?

The log indicates that you have a missing ")"

Unexpected end of input. Perhaps there is a missing "," or ")".
Trying to parse arguments of function "new script".
Line 2 Column 59: ...nding ), replace table );►...

You have dropped the training ")" for the New Script statement.

Your code

Eval(
	Parse(
		"d3<<new script(\!"test\!",d3 = Current Data Table();
d3 << Sort( By( 6 ), Order( Descending ), replace table );"
	)
);

Correct code

Eval(
	Parse(
		"d3<<new script(\!"test\!",d3 = Current Data Table();
d3 << Sort( By( 6 ), Order( Descending ), replace table ));"
	)
);
Jim