Choose Language Hide Translation Bar
Highlighted
dconradgreen
Level I

Save script to data table Without Opening Graph

I've written a script that loops and generates graphs from a table based on conditions. I want to save each of those graphs to the table as a script so that if I needed to view that data I can go back to it. When I use the function "<<Save script to data table" the graph-script successfully saves to the table. It also open the graph once the looping is complete. I was wondering if there was a way to save the script to the table without opening the graph (or running the script that is being saved).

 

A boiled down version of the script save looks like this...

 

a = Expr(
    new_graph = Graph Builder(
        Size( 1000, 800 ),
        Show Control Panel( 0 ),
        Variables( X( :variable1 ), Y( :variable1 ) )
    )
);

a << Save script to data table( "name_of_graph_script" );

 

 

**I've also tried the last line as the following but the graph still appears after running this...

a << Save script to data table( "name_of_graph_script", <<Prompt( 0 ) );
3 REPLIES 3
Highlighted
txnelson
Super User

Re: Save script to data table Without Opening Graph

You want to use the Invisible option on the Graph Builder statement, and also to close the invisible object at the end.

a = Expr(

	new_graph = Graph Builder(
		invisible,
		Size( 1000, 800 ),
		Show Control Panel( 0 ),
		Variables( X( :variable1 ), Y( :variable1 ) )
	);

	a << Save script to data table( "name_of_graph_script" );
	
	new_graph << close window;

)
Jim
Highlighted
Ryan_Gilmore
Community Manager Community Manager

Re: Save script to data table Without Opening Graph

The New Script command may be helpful to you as well, e.g.

 

Data Table( "my table" ) << New Script(
    "name_of_graph_script",
    new_graph = Graph Builder(
        Size( 1000, 800 ),
        Show Control Panel( 0 ),
        Variables( X( :variable1 ), Y( :variable2 ) )
    )
);
Highlighted
ih
ih
Level VII

Re: Save script to data table Without Opening Graph

Expanding this a bit to apply it to multiple columns:

 

Names default to here(1);

dt = Open("$Sample_Data/Semiconductor Capability.jmp");

AddGraphScript = function( {dt, v1, v2},
	Eval( Eval Expr(
		dt << New Script( 
			"Graph: " || ( v1 << Get Name) || " v " || (v2 << Get Name);
		, 
			new_graph = Graph Builder(
					Size( 1000, 800 ), 
					Show Control Panel( 0 ), 
					Variables( X( Expr( Name Expr( v1 ) ) ), Y( Expr( Name Expr( v2 ) ) ) )
			);
		)	
	) )
);

//for a single graph
AddGraphScript(dt, Expr( :NPN1 ), Expr( :PNP3) );

//for a selected columns
dt << Select Columns( {:PNP3, :IVP1, :PNP4} );
cols = dt << Get Selected Columns();
for( c = 1, c <= n items( cols ), c++, AddGraphScript( dt, Expr( :PNP2 ), cols[c] ) );
Article Labels