There is no New Script() function. Instead, to open a new script window, you use the New Window() function and then send it a message to tell it that it’s a script window:
win = New Window( "title", <<Script, "Initial Contents" );
In the New Window() example above, win is a reference to the display box that is the entire window. To write to a script window, you first need to get a reference to the part of the display box that you can write to, which is called a Script Box():
ed = win[Script Box( 1 )];
Using the reference ed, you can add text, remove text, and get the text that is already there.
ed << Get Text();
"Initial Contents"
Use the Set Text message to set all the text in the script window. The following message clears all text in the Script Window and then adds aaa=3; followed by a return:
ed << Set Text( "aaa=3;\!N" );
Use the Append message to add additional text to the end of the script window.
ed << Append Text( "bbb=1/10;" );
ed << Append Text(" \!Nccc=4/100;" );
Use the Get Line Text message to get the text at the line of a specified line number. Use the Set Line Text message to replace a specified line of text with new text.
ed << Get Line Text( 2 );
ed << Set Line Text( 2, "bbb = 0.1;" );
Use the Get Line Count message to get the total number of lines in the script. The Get Lines message returns a list of each line in the script as a string.
ed << Get Line Count();
ed << Get Lines();
Use the Reformat message to automatically format a script for easier reading.
ed << Reformat();
Use the Save Text File message to save the script to a text file with a .jsl extension.
Save Text File(
	"$DOCUMENTS/Example.txt",
	"The quick brown fox"
);
ed << Run();
To close the script window, send the window the Close Window message, just like you can do with any JMP window.
win << Close Window( nosave );