cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
JMP is taking Discovery online, April 16 and 18. Register today and join us for interactive sessions featuring popular presentation topics, networking, and discussions with the experts.
Choose Language Hide Translation Bar
terapin
Level VI

JSL to Select Project Tab and Run Script

Folks,

 

I'm brand new to working with Projects and am having some difficulty achieving various things that I routinely do in JSL.  My Project has 4 data tables and I'm trying to select one of them and then run a particular script that is listed in that data table.  I've looked at the help information for Projects but can't quite figure out how to accomplish this.  Any suggestions/ideas would be greatly appreciated.

1 ACCEPTED SOLUTION

Accepted Solutions

Re: JSL to Select Project Tab and Run Script

Use Project << Run Script() to run JSL inside the project from outside of it:

// 1. Create a project and open two data table in it
p = new Project();

p << Run Script(
	Open("$SAMPLE_DATA/Big Class.jmp");
	Open("$SAMPLE_DATA/Airline Delays.jmp");
);

// 2. Run the a saved script from each table
p << Run Script(
	Get Data Table("Big Class") << Run Script("Distribution");
	Get Data Table("Airline Delays") << Run Script("Graph Builder Heatmap");	
);

// 3. Optionally, make Big Class the visible tab
wait(0);
p << Run Script(
	Get Window("Big Class") << Bring Window To Front();
);   

 

View solution in original post

7 REPLIES 7

Re: JSL to Select Project Tab and Run Script

To clarify, are you wanting to use JSL in projects to do something you usually do with JSL outside of projects, or use the gui interface in projects to do what you normalyly do in JSL?

Re: JSL to Select Project Tab and Run Script

With very few exceptions, JSL scripts will work the same inside projects as they did before. So if you have JSL that does what you need already, running that JSL from a project tab is most likely all you need to do. If there are errors, or it's not working like you'd expect, I can try to help you figure those out.
terapin
Level VI

Re: JSL to Select Project Tab and Run Script

Hi Aaron,

 

I'm trying to use JSL to work with but outside an existing Project.  That is, with an open Project I want to run an external script that selects a particular tab and runs a script saved with that tab.  For example, with data tables Big Class, Abrasion, and Bicycle Moved to a Project (I tried to send my archiived version of this project but an error says "The contents of the attacment doesn't match its file type"), I want a JSL file that is saved outside the Project to Open the Project, Select Tab Big Class, Run Distribution script, switch to Tab Bicycle and run Fit Model script.  I can open the Project without any trouble, but can't accomplish the rest.  

Re: JSL to Select Project Tab and Run Script

Use Project << Run Script() to run JSL inside the project from outside of it:

// 1. Create a project and open two data table in it
p = new Project();

p << Run Script(
	Open("$SAMPLE_DATA/Big Class.jmp");
	Open("$SAMPLE_DATA/Airline Delays.jmp");
);

// 2. Run the a saved script from each table
p << Run Script(
	Get Data Table("Big Class") << Run Script("Distribution");
	Get Data Table("Airline Delays") << Run Script("Graph Builder Heatmap");	
);

// 3. Optionally, make Big Class the visible tab
wait(0);
p << Run Script(
	Get Window("Big Class") << Bring Window To Front();
);   

 

terapin
Level VI

Re: JSL to Select Project Tab and Run Script

Dang,

 

That was easy.  I wasn't aware that I had to use Run Script for each command or set of commands. 

 

It's now working very well except for being able to pass a variable as the Window or Data Table Name.  I'm using JSL to process data from numerous sites and I pull the site id from the opened data file and then use that in many other sections of JSL to save, rename, move the data files to site specific directories.  Unfortunately, I can't pass my variable, stn, into the Window or Data Table names as shown below.  Is it possible to do this with Projects, and if so, do you have a suggestion for how to accomplish it?

 

Project << Run Script( Get Data Table( stn || " Amp_Hr Per Day" ) ); << Run Script( "OP of Parameters w/ PAR" );

Project << Run Script ( Get Window( stn || " Amp_Hr Per Day" ) << Bring Window to Front() );

Re: JSL to Select Project Tab and Run Script


@terapin wrote:

Dang,

 

That was easy.  I wasn't aware that I had to use Run Script for each command or set of commands. 

 

It's now working very well except for being able to pass a variable as the Window or Data Table Name.  I'm using JSL to process data from numerous sites and I pull the site id from the opened data file and then use that in many other sections of JSL to save, rename, move the data files to site specific directories.  Unfortunately, I can't pass my variable, stn, into the Window or Data Table names as shown below.  Is it possible to do this with Projects, and if so, do you have a suggestion for how to accomplish it?

 

Project << Run Script( Get Data Table( stn || " Amp_Hr Per Day" ) ); << Run Script( "OP of Parameters w/ PAR" );

Project << Run Script ( Get Window( stn || " Amp_Hr Per Day" ) << Bring Window to Front() );


It's intentional that Projects have their own JSL scopes, but that can cause issues when trying to share variables between them. One way to do that is to use Eval/EvalExpr. It's not pretty, but it does the trick:

win name = "Big Class";
Eval(
	Eval Expr(
		project << Run Script( Get Window( Expr( win name ) ) << Bring Window To Front() )
	)
); 
 

Re: JSL to Select Project Tab and Run Script

Also, you shouldn't need separate Run Script messages for each block. I just did that for readability. You may need the wait(0) call, however, if you're trying to open something and then immediately set focus to it, as otherwise the tab may not have finished loading by the time we try to bring it forward.