cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Try the Materials Informatics Toolkit, which is designed to easily handle SMILES data. This and other helpful add-ins are available in the JMP® Marketplace
Choose Language Hide Translation Bar
BHarris
Level VI

How do I automatically add all columns to the Column Switcher in .jsl

I'm very much a beginner with JSL, I'm still learning --

 

I have many files that I need to review with Graph Builder, and each has a different number of columns.  The only constant is that I know I want column 1 as the Overlay, column 2 in the X-axis, column 3 in the Y-axis, and all the rest of the columns in the Column Switcher.  I'd love to have a script that would open up all the Graph Builder windows for all the currently-open data tables with these settings, but I don't know how to do that.  This is the closest I've gotten:

 

Graph Builder(
	Size( 1900, 1200 ),
	Variables(
		X( :Column(2) ),
		Y( :Column(3) ),
		Overlay( :Column(1) )
	),
	Elements( Points( X, Y, Legend( 10 ) ), Line( X, Y, Legend( 11 ) ) ),
	Column Switcher( :Column(3) ),
	SendToReport(
		Dispatch(
			{},
			"",
			ScaleBox
		)
	)
);

 

The two things I need help with:  (1) figure out how to set the Column Switcher to automatically load up all the columns in the data table without asking me, and (2) wrap this script in a loop that iterates over all the open data tables.

 

Thanks in advance!

10 REPLIES 10
BHarris
Level VI

Re: How do I automatically add all columns to the Column Switcher in .jsl

Thanks to those here who helped, I feel like I didn't add much of my own here.  This is basically what I ended up with:

 

The goal was to have a script that would go through a folder full of text files one at a time, load it, and bring up a Graph Builder window with some settings pre-set, then when Graph Builder is closed, it automatically opens the next one.

 

The approach I used was to manage it with global variables:  "regFlist" is the list of files left to open, and "stopReg" is a flag that when turned on interrupts the process.

 

There are two scripts:  (1) reg_Next.jsl -- checks regFlist, and if it's empty, it asks for a folder to use; otherwise it loads the next file from the regFlist list (if regStop is not set), (2) reg_Stop.jsl -- simply empties regFlist and sets the regStop variable; used to stop the process early.

 

I'm a total beginner with .jsl, so I'm very open to any feedback/constructive-criticism.

 

reg_Next.jsl

 

//!

// use global variables (since hey, what could go wrong? ;) ) Names Default To Here( 0 ); // get path to self selfPath = get default directory() || "/reg_Next.jsl"; // check to see if user has requested a stop If( stopReg == 1 , stopReg = 0; regFlist = {}; Stop(); ); // initialize list of files to review if there aren't any in the list If( Is Empty( regFlist ) | N Items( regFlist ) < 1, jmpDir = Pick Directory( "Select the jmp directory." ); regFlist = Files In Directory( jmpDir ); ); // open data table and remove it from the regFlist dt = Open( jmpDir || "/" || regFlist[1] ); regFlist = Remove( regFlist, 1 ); // set up for column switcher colList = dt << get column names( string ); col1 = colList[1]; col2 = colList[2]; col3 = colList[3]; Remove From( colList, 1, 2 ); // open graph builder gb = dt << Graph Builder( size( 800, 600 ), Variables( X( As Column( col2 ) ), Y( As Column( col3 ) ), Overlay( As Column( col1 ) ) ), Elements( Points( X, Y, Legend( 10 ) ), Line( X, Y, Legend( 11 ) ) ) ); cs = gb << Column Switcher( col3, colList ); // set up mechanism to re-run myself when graph builder is closed If( N Items( regFlist ) == 0, gb << on close( Close( dt, nosave ) ), gb << on close( Close( dt, nosave ); Open( selfPath, Run JSL( 1 ) ); ) );

reg_Stop.jsl

//!
Names Default To Here( 0 );
regFlist = {};
stopReg = 1;