For the latest version of JMP Help, visit JMP.com/help.


Scripting Guide > Creating Projects > Running Scripts in a Project
Publication date: 11/29/2021

Running Scripts in a Project

When you run a script outside of a project, the reports generated by the script appear in different windows. When you run a script inside a project, the reports appear in different tabs inside the project.

Running a JSL script outside of a project

Open a Script Editor window by selecting File > New > Script. Paste and run the following script:

dt = Open( "$SAMPLE_DATA/Big Class.jmp" );
dt << Run Script( "Bivariate" );
dt << Run Script( "Distribution" );
Wait( 2 );
Get Window( "Big Class - Distribution" ) << Close Window();

Note that this script opens three JMP windows: one for the data table and one for each report. Close the reports and then the data table.

Running a JSL script inside of a project

Create a new project by selecting File > New > Project. From the project window, create a new script editor window by selecting File > New > Script. Note that the script editor window opens as a tab in the project. Paste the same JSL script you previously ran into the script editor and run it:

dt = Open( "$SAMPLE_DATA/Big Class.jmp" );
dt << Run Script( "Bivariate" );
dt << Run Script( "Distribution" );
Wait( 2 );
Get Window( "Big Class - Distribution" ) << Close Window();

Note that this time, the data table and the reports all opened as tabs in the project, and that Get Window() correctly found the distribution tab. In general, all JSL functions that open, find, manipulate, and close JMP windows, tables, and reports work from within a project the same as they would outside projects.

Running a JSL script using a project’s Run Script message

You can use the Run Script message to run JSL in the project’s context. Open a Script Editor window, then paste and run the following code:

project = New Project();
project << Run Script(
	dt = Open( "$SAMPLE_DATA/Big Class.jmp" );
	dt << Run Script( "Bivariate" );
	dt << Run Script( "Distribution" );
	Wait( 2 );
	Get Window( "Big Class - Distribution" ) << Close Window();
);

Note that the script inside the Run Script message runs the same as if it had been in a script editor window inside the project.

Scoping Variables

JMP can have several projects open at the same time, as well as items not open in any project. Each project has its own global scope, which prevents conflicts caused by identically named variables in different projects. In the rare case that you do want to share specific variables among all opened projects, use the ::: root operator.

Want more information? Have questions? Get answers in the JMP User Community (community.jmp.com).