cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Browse apps to extend the software in the new JMP Marketplace
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.

1 ACCEPTED SOLUTION

Accepted Solutions
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

View solution in original post

30 REPLIES 30
uday_guntupalli
Level VIII

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

@powerpuff
        Look for a button which say "Source" and right click that in the table 

 

image.png

 

        If you hit - "edit", you will be able to see the script that JMP generated for the table. 

Best
Uday
powerpuff
Level IV

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

I was actually talking about the little red button after you open up one of the reports below 'source' option. Capture.PNG

uday_guntupalli
Level VIII

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

@powerpuff,
         You should be able to save that as well to a Script Window as shown below. 
      image.png

Best
Uday
powerpuff
Level IV

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

Yes, I know I can do that manually, my question was: Can this be done in a jsl script?

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

Not sure if this is what you're trying to do, but if you want to dynamically get a JSL script for a Platform into a JSL expresison variable, you can send the Get Script message to the platform. In the below example, the script variable will have the same script that would appear in the Script Window if you save to it from the Red Triangle Menu.

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

script = dist << Get Script();

Script variable:

Distribution(
	Continuous Distribution( Column( :weight ) ),
	Nominal Distribution( Column( :age ) )
)
Justin
powerpuff
Level IV

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

Hi Justin,

Thank you for your response. Can you tell me how do you choose the script variables? I am trying to extract a script from Stepwise regression. Thanks.
txnelson
Super User

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

I don't think you want to parse through the script, when you can easily get the model variables by retrieving them directly from the ouput of the run Model.  See the simple script below

Names Default To Here( 1 );
dt = Open( "$SAMPLE_DATA/Fitness.jmp" );

// Run the Stepwise and the resulting model
obj = Fit Model(
	Y( :Oxy ),
	Effects(
		:Runtime,
		:Weight,
		:RunPulse,
		:RstPulse,
		:MaxPulse
	),
	Personality( Stepwise ),
	Run
);
// run the stepwise
obj << Go;
// run the model
mod = obj << Run Model;

// Capture from the Effect Tests output, the list of 
// variables that were run in the model
Variables = report(mod)["EffectTests"][StringColBox(1)]<<get;
show(Variables);
Jim
powerpuff
Level IV

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

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.
txnelson
Super User

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

Going down the path of parsing a script is sometimes the only way to get what you need.  However, it has been my experience that unless you are looking for things a user may have changed and you need to pick those changes up, reconstructing the code from scratch is typically a simpler approach.

BTW, don't forget to examine the user preferences.  The scripts extracted will not provide you with settings that a user may have set by setting preferences.

Jim