cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Choose Language Hide Translation Bar
Neo
Neo
Level VI

How to write a JSL script to call and run other scripts without opening a script window but showing just a cancel button?

I want to write a JSL script say myScript.jsl which when double clicked to open does not open itself in the script window but runs other scripts called inside myScript.jsl while showing a modal window displaying "Script Running" and a Cancel button to stop further execution.

If this is possible to do in JSL, could I please have an example?

When it's too good to be true, it's neither
1 ACCEPTED SOLUTION

Accepted Solutions
Byron_JMP
Staff

Re: How to write a JSL script to call and run other scripts without opening a script window but showing just a cancel button?

The key to making JSL auto run is adding this to the very first line of the script.  

 //!

 

If you double click on the script it will run and not open the script file.

for example, past this in an empty script and save it, then double click on it.

//!
Speak("ha, ha, I just ran a script.");
JMP Systems Engineer, Health and Life Sciences (Pharma)

View solution in original post

4 REPLIES 4

Re: How to write a JSL script to call and run other scripts without opening a script window but showing just a cancel button?

This should do what you are asking. I haven't verified that the cancel button works, as JMP ran all the scripts in the folder on my computer very quickly.

/*JMP STATISTICAL DISCOVERY LLC (“JMP”) PERMITS THE USE OF THIS COMPUTER SOFTWARE CODE (“CODE”) ON AN AS-IS BASIS AND AUTHORIZES YOU TO USE THE CODE SUBJECT TO THE TERMS LISTED HEREIN.  BY USING THE CODE, YOU AGREE TO THESE TERMS.  YOUR USE OF THE CODE IS AT YOUR OWN RISK.  JMP MAKES NO REPRESENTATION OR WARRANTY, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO, WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, NONINFRIGEMENT, AND TITLE, WITH RESPECT TO THE CODE.
You may use the Code solely as part of a software product you currently have licensed from JMP, JMP’s parent company SAS Institute Inc. (“SAS”), or one of JMP’s or SAS’s subsidiaries or authorized agents (the “Software”), and not for any other purpose.  The Code is designed to add functionality to the Software but has not necessarily been tested.  Accordingly, JMP makes no representation or warranty that the Code will operate error-free.  JMP is under no obligation to maintain, support, or continue to distribute the Code.
Neither JMP nor its licensors shall be liable to you or any third-party for any general, special, direct, indirect, consequential, incidental, or other damages whatsoever arising out of or related to your use or inability to use the Code, even if JMP has been advised of the possibility of such damages.  Except as otherwise provided above, the Code is governed by the same agreement that governs the Software.  If you do not have an existing agreement with JMP or SAS governing the Software, you may not use the Code.
JMP and all other JMP Statistical Discovery LLC product or service names are registered trademarks or trademarks of JMP Statistical Discovery LLC in the USA and other countries.  ® indicates USA registration.  Other brand and product names are registered trademarks or trademarks of their respective companies.
*/
Names Default To Here( 1 );

//get scripts to run
lstScripts = Files In Directory( "$Documents/My Scripts/" );

//set up stop button
nw = New Window( "Running",
	Text Box( "Running all the scripts" ),
	Button Box( "Cancel", Stop() )
);

For Each( {i}, lstScripts,
	If( Word( -1, i, "." ) == "jsl", //make sure it's a .jsl file
		include( "$Documents/My Scripts/" || Char( i ) ); //run it
		Wait( 0 ); //this allows JMP to recognize if cancel button has been pressed
	)
);

nw << close window;
Neo
Neo
Level VI

Re: How to write a JSL script to call and run other scripts without opening a script window but showing just a cancel button?

@Jed_Campbell  Thanks, 

It is not clear to me how your script (slightly modified version below) calls the main script in the path.

In my case the main script calls all the other scripts. This is the functionality I need.

Also, is it possible to capture and display the log which displayed (at the bottom) on my main script in the window (nw) generated in your script. Any way in my case, the original and the modified below script did not work.

Names Default To Here( 1 );

 path2Scripts = "C:\Users\UserName\Documents\Scripts_v0.1.4"; //change this as necessary

//get scripts to run
lstScripts = Files In Directory(path2Scripts);

//set up stop button
nw = New Window( "Running", << modal, 
	Text Box( "Running all the scripts" ),
	Button Box( "Cancel", Stop() )
);

For Each( {i}, lstScripts,
	If( Word( -1, i, "." ) == "jsl", //make sure it's a .jsl file
		include( path2Scripts || Char( i ) ); //run it
		Wait( 0 ); //this allows JMP to recognize if cancel button has been pressed
	)
);

nw << close window;

 What did I miss? 

When it's too good to be true, it's neither

Re: How to write a JSL script to call and run other scripts without opening a script window but showing just a cancel button?

Ah, I think I misunderstood your original question. The script I provided is both showing a cancel button and running all the scripts in a folder. If I understand correctly, you already have the script made to run all the other scripts. In this case, the script for this file should look something like:

//!
//the //! comment on the first line causes the script to run, rather than open

Names Default To Here (1);
clear log();

//set up stop button
nw = New Window( "Running", << modal, 
	Text Box( "Running all the scripts" ),
	Button Box( "Cancel", Stop() )
);

include("path/to/main/scipt.jsl"); //your file that runs all the scripts

logtxt = get log();

You'll want to be sure to insert wait(0); statements in your main script file. Otherwise, JMP may not allow the cancel button to work.

Byron_JMP
Staff

Re: How to write a JSL script to call and run other scripts without opening a script window but showing just a cancel button?

The key to making JSL auto run is adding this to the very first line of the script.  

 //!

 

If you double click on the script it will run and not open the script file.

for example, past this in an empty script and save it, then double click on it.

//!
Speak("ha, ha, I just ran a script.");
JMP Systems Engineer, Health and Life Sciences (Pharma)