While @cwillden code will save the script for the New Window(), the unfortunate item is that there are issues with the script created in JMP from a New Window().
I have been more successful in creating in the JSL, an expression of the script I am going to create, and then running the script from the expression, and then secondly, converting the literal string and saving it as a script to the data table.
Names Default To Here( 1 );
dt = Current Data Table();
x = Expr(
win = New Window( "y vs x",
V List Box(
Fit Group( Bivariate( Y( :height ), X( :weight ) ) )
)
)
);
Eval( x );
Eval(
Substitute(
Expr(
dt << New Script( "y vs x", __x__ )
),
Expr( __x__ ), Eval Expr( x )
)
);
Jim