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

Is there an easy way open a script generated graph with the script name as a title?

Hi, I often find myself saving a few scripts that used the same application (e.g. Graph builder) to a datatable. When you run these scripts the window title of the graph will automatically be "Datatable - graph builder".

When multiple scripts are run this creates the situation of having windows open with titles "Graph Builder 2", "Graph Builder 3" and I lose track of which script generated which window.

 

I've been using a code around my script like below example, however when I make a few changes I cannot simply perform the "save script to datatable" option without overwriting this naming convention.

w = Graph Builder(
// graph script
);
w << set window title( "script name" )

 

 

Example: script opens a window with generic "Graph builder" title.

mvanderaa1_0-1660116956611.png

 

1 ACCEPTED SOLUTION

Accepted Solutions
mvanderaa1
Level IV

Re: Is there an easy way open a script generated graph with the script name as a title?

Based on the feedback in this thread, I conclude that there is no easy way to do this in JMP.

View solution in original post

9 REPLIES 9
Byron_JMP
Staff

Re: Is there an easy way open a script generated graph with the script name as a title?

If your question is, "how do I save a script to the data table with a specified name?"  Then I think I have an answer for you.


dt=current data table();

obj=dt<<Graph Builder(
	Show Control Panel( 0 ),
	Variables( X( :Temp ), Y( :pH ) ),
	Elements( Points( X, Y, Legend( 3 ) ), Ellipse( X, Y, Legend( 5 ) ) )
);
//  app<<save script to data table ( <name> , < <<prompt(0|1)>, < <<Replace(0|1)> );
obj << Save Script to Data Table("New GB");

...but I'm not sure if that was what you were asking?

JMP Systems Engineer, Health and Life Sciences (Pharma)
mvanderaa1
Level IV

Re: Is there an easy way open a script generated graph with the script name as a title?

Hi Byron, that was not what I was asking. I'm looking for the window name that is opened to have the script name. Like I said I can do it once by adding below code around my script. But my problem then is that I cannot alter my graphs (e.g. change axes and visuals) without having to copy/paste the new graph script into my datatable script.

w = Graph Builder(
// graph script
);
w << set window title( "script name" )

mvanderaa1_0-1660545123241.png

 

I just tried a method of creating a second script that runs the graph builder script and changes the window name. This is basically what I want because I can make changes to the graph and "save to datatable" again, overwriting my original graph. I don't need any copy/pasting anymore. See "big class 2.jmp" in attachments, I would just run the "run myGraph1" script. It would be nice of course if I wouldn't need the second script to initiate my graph script.

 

 

pauldeen
Level VI

Re: Is there an easy way open a script generated graph with the script name as a title?

Is this what you are looking for?

w << get window title()
ih
Super User (Alumni) ih
Super User (Alumni)

Re: Is there an easy way open a script generated graph with the script name as a title?

What if instead of changing the window title you just changed the name of the outline box in that window?  You can do that by double clicking on the name, and that is maintained in the saved script.

 

     ih_0-1661514076331.png

A sidebar: this might be moving farther away from changing graphs without copy/pasting, but if you have a bunch of graphs that you often look at for a dataset, you might consider building a dashboard or window that contains all of them, with some headings and text to give each context.

 

 

mvanderaa1
Level IV

Re: Is there an easy way open a script generated graph with the script name as a title?

I suppose the behaviour I'm struggling with can be circumvented by using a dashboard indeed. I'll try to adapt my way of working in JMP.

mvanderaa1
Level IV

Re: Is there an easy way open a script generated graph with the script name as a title?

Based on the feedback in this thread, I conclude that there is no easy way to do this in JMP.

Re: Is there an easy way open a script generated graph with the script name as a title?

I hope that I understand what you are asking. This script illustrates one way that might work. The first part is just a way to have some open (data table and Graph Builder) for which the rest of the script to work. That is the part that you might use with your own open Graph Builder objects. You could save this script as an add-in so then it is just a matter of selecting a menu command when you want to use it.

 

Names Default to Here( 1 );

// example of Graph Builder
dt = Open( "$SAMPLE_DATA/Big Class.jmp" );
gb = dt << Graph Builder(
	Size( 534, 456 ),
	Show Control Panel( 0 ),
	Variables( X( :height ), Y( :weight ) ),
	Elements( Points( X, Y, Legend( 3 ) ), Smoother( X, Y, Legend( 4 ) ) )
);

// now the script to save table script with desired name

// ask user for name of script
dialog = New Window( "Name of Script", << Modal,
	Panel Box( "Script Name",
		Line Up Box( N Col( 2 ),
			Text Box( "Name:" ),
			teb = Text Edit Box( "Graph Builder Script" )
		),
		H List Box(
			Button Box( "OK",
				name = teb << Get Text;
			),
			Button Box( "Cancel" )
		)
	)
);
If( dialog["Button"] == -1, Throw( "User cancelled" ) );

// save script for current instance of Graph Builder
window = Get Window List();
wName = window << Get Window Title;
nWindows = N Items( window );
For( i = nWindows, i > 0, i--,
	If( Contains( wName[i], "Graph Builder" ),
		Break();
	);
);
obj = window[i]["Graph Builder"] << Get Scriptable Object;
obj << Save Script to Data Table( name, << Prompt( 0 ), << Replace( 1 ) );

// update table script
script = dt << Get Property( name );
Eval(
	Substitute(
		Expr(
			dt << Set Property( nnn,
				w = sss;
				w << Set Window Title( nnn )
			)
		),
		Expr( sss ), Name Expr( script ),
		Expr( nnn ), name
	)
);
SpannerHead
Level III

Re: Is there an easy way open a script generated graph with the script name as a title?

If I wanted to run something similar for a oneway plot, how can I modify this?  Replacing "Graph Builder" with "Oneway" doesn't seem to work.

SpannerHead
Level III

Re: Is there an easy way open a script generated graph with the script name as a title?

With some help from a colleague (Thanks Andrew!) , we came up with this.

 

clear Globals();
Delete Symbols();
// save script for current instance of Fit Group
window = Get Window List();
wName = window << Get Window Title;
nWindows = N Items( window );
For( i = nWindows, i > 0, i--,
	If( Contains( wName[i], "Fit Y by X" ),
	
		obj = window[i]["Fit Group?"] << Get Scriptable Object;
		Show(obj);
		obj << Save Script for All Objects;
Break();
	);
);

Can be adapted to grab the script for any kind of a graph by substituting the items in quotes.  The ability to use a ? as a wildcard in a matrix is priceless.