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
powerpuff
Level IV

Is it possible to extract the script behind a JMP Table?

For example, we can manually right click on the top-left red icon in a report and hit save script --> To script window. 

Is there a way to do this as a JSL script? This is because I want to manipulate the script to make combined data table further. Thanks for the help.

30 REPLIES 30

Re: Is it possible to extract the script behind a JMP Table?

If you really want the script to appear in a Script Window, you can use the Save Script to Script Window message. But I am not sure what you would do with that.

Names Default To Here( 1 );
dt = Open( "$SAMPLE_DATA\Big Class.jmp" );
dist = dt << Distribution(
	Continuous Distribution( Column( :weight ) ),
	Nominal Distribution( Column( :age ) )
);

dist << Save script to script window();

Or you could always put the script into a new script editor window from the Get Script result. You could add to this script yourself, but I still don't think I am following what you are looking to do.

Names Default To Here( 1 );
dt = Open( "$SAMPLE_DATA\Big Class.jmp" );
dist = dt << Distribution(
	Continuous Distribution( Column( :weight ) ),
	Nominal Distribution( Column( :age ) )
);

script = Char( dist << Get Script() );

nw = New Window( "Not the Script Window",
	<<Script,
	Names Default To Here( 1 );
	"\[dt = Open( "$SAMPLE_DATA\Big Class.jmp" ); obj = dt<<]\" || script
);
nw[ScriptBox(1)] << Reformat();
Justin
powerpuff
Level IV

Re: Is it possible to extract the script behind a JMP Table?

I want to write a script that would go to the JMP report and do the save script to --> script window and then make additions to the script so that I can acquire only certain columns from the report table. I have many tables that I need data from, hence I want to be able to extract the script and manipulate it accordingly.

Thanks

David_Burnham
Super User (Alumni)

Re: Is it possible to extract the script behind a JMP Table?

This code will find table scripts for fit model and pop them into a script window

dt = open("$SAMPLE_DATA/Big Class.jmp");

// check whether the current data table contains any scripts
// for least squares regression
lstModelNames = {};    // name of scripts
lstModelScripts = {};  // script contents
If (NTable()>0,
	lstTableScripts = Current Data Table() << Get Table Script Names;
	For (i=1,i<=NItems(lstTableScripts),i++,
		s = Current Data Table() << Get Property(lstTableScripts[i]);
		str = Char(NameExpr(s));
		If (Left(str,7)!="JMP App" & Contains(str,"Standard Least Squares") & !Contains(str,"Generalized Regression"),
			InsertInto(lstModelNames,lstTableScripts[i]);
			InsertInto(lstModelScripts,NameExpr(s));
		)
	)
);

// launch script windows
For (i=1,i<=NItems(lstModelScripts),i++,
	New Window(lstModelNames[i], <<Script,
		Char(lstModelScripts[i])
	);
);

But if they are in a script window then you have to manually make the edits.  Alternatively just treat the scripts as either expressions or as strings and manipulate them in code.  For example:

// run the model invisiblely and create a handle 'fm'
// that references the model object
s = lstModelScripts[1];
str = Char(NameExpr(s));		
str = "fm =" || str;
SubstituteInto(str,"Fit Model(","Fit Model(Invisible,");
Eval(Parse(str));
// ensure summary of fit is available
fm << Summary Of Fit(1);
// grab the R-sq from the report window
rep = fm << Report;
ob = rep[OutlineBox("Summary of Fit")];
values = ob[NumberColBox(1)] << Get;
Rsquare = values[1];
// close the model object
rep << Close Window;
show(RSquare);
-Dave
powerpuff
Level IV

Re: Is it possible to extract the script behind a JMP Table?

This is somewhat closer to what I was looking for. Thanks a lot. 

powerpuff
Level IV

Re: Is it possible to extract the script behind a JMP Table?

Also, the script that I acquire is spread horizontally across the script window. Is it possible to acquire the script vertically in the script window?

Re: Is it possible to extract the script behind a JMP Table?

You can reformat the script in the ScriptBox to make it appear nicely in the Script Window.

Window( "Script Window" )[Script Box(1)] << Reformat(); 
Justin
powerpuff
Level IV

Re: Is it possible to extract the script behind a JMP Table?

This somehow doesnt seem to work. The output I acquire looks like this.cap.PNG

 

Whereas I am looking for something like this:

cap1.PNG

 

David_Burnham
Super User (Alumni)

Re: Is it possible to extract the script behind a JMP Table?

right-click and select reformat script

-Dave
Jeff_Perkinson
Community Manager Community Manager

Re: Is it possible to extract the script behind a JMP Table?

@powerpuff, I've read this thread a couple of times and I'm not sure I understand what problem you're trying to solve by getting a platform script into a script window through JSL.

 

This is a rather unusual and, while I can imagine situations where it might be useful, it's not something that strikes me as general purpose.

 

Could you start back at the beginning and describe as fully as possible what you're trying to do?

 

Are you writing a script that others will run or only for yourself?

 

You said:



@powerpuff wrote:

I want to extract the script to a script window and add some more code to it to make multiple combined data tables and then make a resulting table from columns I extract using the make combined data table function.

And



@powerpuff wrote:

I want to write a script that would go to the JMP report and do the save script to --> script window and then make additions to the script so that I can acquire only certain columns from the report table. I have many tables that I need data from, hence I want to be able to extract the script and manipulate it accordingly.

Can you expand on what you mean by "add some more code to it" and "acquire only certain columns from the report table"?

 

There are lots of ways to manipulate reports and data directly in JSL without having to go through the script editor to manipulate a script you retrieved through JSL. We just need to understand more of what your ultimate goal is rather than the solution you headed down using the script window.

-Jeff
powerpuff
Level IV

Re: Is it possible to extract the script behind a JMP Table?

I want to be able to write a script that would make combined data table for 

1) Summary of Fit

2) Analysis of Variance

3) Scaled Estimate 

for different JMP Tables and then extract only certain columns from these 3 combined data tables. I want to have a single script that should be able to work for all the tables. Does that make sense? Please let me know if there's any other way I can achieve something like this. Thanks.