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
matt7109
Level III

Multiple data tables open

Hey, 

I have a script that produces an output of 3 different data tables, each displaying unique data. Upon completion of the script, the 3 tables pop up separatley, bombarding the user with them. Is there anyway these 3 tables can be displayed in neater way, or even all under tha same window?

 

Thanks!

Matt

3 ACCEPTED SOLUTIONS

Accepted Solutions
ian_jmp
Staff

Re: Multiple data tables open

For 'the same window' part, you could try something like:

NamesDefaultToHere(1);

dt1 = Open("$SAMPLE_DATA/Big Class.jmp", Invisible);
dt2 = Open("$SAMPLE_DATA/Bands Data.jmp", Invisible);

win = NewWindow("Both Tables", << OnClose(onCloseScript), 
		PanelBox(dt1 << getName, DataTableBox(dt1)),
		PanelBox(dt2 << getName, DataTableBox(dt2))
	);
onCloseScript = Expr(Close(dt1, NoSave); Close(dt2, NoSave));

View solution in original post

Re: Multiple data tables open

If you wanted a way to show the interactive data tables in the same window, you could use the New Data Box() message to create a DataBrowserBox for each of the tables. See my example below for details.

Names Default To Here( 1 );
// open the tables as invisible
dt1 = Open( "$SAMPLE_DATA\Big Class.jmp", invisible );
dt2 = Open( "$SAMPLE_DATA/Bands Data.jmp", Invisible );

// Create a window with both tables shown
New Window( "Both Tables",
	<<OnClose(
		Try( Close( dt1, NoSave ) );
		Try( Close( dt2, NoSave ) );
	),
	H Splitter Box(
		size( 1200, 800 ),
		a = dt1 << New Data Box(), // Returns DataBrowserBox
		b = dt2 << New Data Box()  // Returns DataBrowserBox
	)
);

// Close the side panels for both tables
a << close side panels();
b << close side panels();

The resulting window:

Capture.PNG

Justin

View solution in original post

Re: Multiple data tables open

Hi @matt7109,

The menu and toolbars you see are limited to one per window. You will need to create your own custom behaviors for actions (like save) that would typically be done using the menu or toolbars. 

The below script creates a red triangle menu that will save the data table within the Outline Box. Notice that I turned on the "Data Table List" in the toolbar so that you can see the current data table. With this method, you can still use the menus (Tables, DOE, Analyze, Graph) that will perform actions on the current data table shown in the data table list.

 

Names Default To Here( 1 );
// open the tables as private
dt1 = Open( "$SAMPLE_DATA\Big Class.jmp", private );
dt2 = Open( "$SAMPLE_DATA\Bands Data.jmp", private );

// Create a function to create each data table to reduce code redundancy
getDataTableOutlineBox = Function( {dt},
	Eval(
		Eval Expr(
			Outline Box( dt << Get Name, // title of the tab
				dt << New Data Box(), //DataBrowserBox
				// Add scripts to the Red Triangle menu for the Outline Box
				<<Set Menu Script(
					{
						"Save As", // Name of the menu item script
						
						// get path to save the data table
						savePath = Pick File(
							"Save JMP Data Table",
							"",
							{"JMP Files|jmp", "All Files|*"},
							1,
							1,
							Expr( dt << get name ) || ".jmp" // evaluate the name of the table when the menu script is added
						);
						// If the user selected a path, save the table at that path
						If( savePath != "",
							Expr( dt ) << save( savePath )
						); 
					
					}
				)
			)
		)
	)
);

// (optional) Turn on the Data Table list for reports so that you can see what the current data table is
Set Toolbar Visibility( "Data Table List", Report, true );

// Create a window with both tables shown
New Window( "Both Tables",
	Suppress AutoHide( 1 ), // Suppress the auto hide so that the toolbars appear
	<<OnClose(
		Try( Close( dt1, NoSave ) );
		Try( Close( dt2, NoSave ) );
	),
	H Splitter Box(
		size( 1200, 800 ),
		getDataTableOutlineBox( dt1 ),
		getDataTableOutlineBox( dt2 ),

	)
);

Below is a screenshot of the window after clicking on the Red Triangle Menu. 

2017-07-13_12-44-55.png

 

Justin

View solution in original post

7 REPLIES 7
txnelson
Super User

Re: Multiple data tables open

You can make them Invisible or Private data tables, or you can Minimize them.  Go to

     Help==>Scripting Index==>Data Table

to see examples of how to do these

Jim
ian_jmp
Staff

Re: Multiple data tables open

For 'the same window' part, you could try something like:

NamesDefaultToHere(1);

dt1 = Open("$SAMPLE_DATA/Big Class.jmp", Invisible);
dt2 = Open("$SAMPLE_DATA/Bands Data.jmp", Invisible);

win = NewWindow("Both Tables", << OnClose(onCloseScript), 
		PanelBox(dt1 << getName, DataTableBox(dt1)),
		PanelBox(dt2 << getName, DataTableBox(dt2))
	);
onCloseScript = Expr(Close(dt1, NoSave); Close(dt2, NoSave));

Re: Multiple data tables open

If you wanted a way to show the interactive data tables in the same window, you could use the New Data Box() message to create a DataBrowserBox for each of the tables. See my example below for details.

Names Default To Here( 1 );
// open the tables as invisible
dt1 = Open( "$SAMPLE_DATA\Big Class.jmp", invisible );
dt2 = Open( "$SAMPLE_DATA/Bands Data.jmp", Invisible );

// Create a window with both tables shown
New Window( "Both Tables",
	<<OnClose(
		Try( Close( dt1, NoSave ) );
		Try( Close( dt2, NoSave ) );
	),
	H Splitter Box(
		size( 1200, 800 ),
		a = dt1 << New Data Box(), // Returns DataBrowserBox
		b = dt2 << New Data Box()  // Returns DataBrowserBox
	)
);

// Close the side panels for both tables
a << close side panels();
b << close side panels();

The resulting window:

Capture.PNG

Justin
matt7109
Level III

Re: Multiple data tables open

Perfect!! Thanks!

matt7109
Level III

Re: Multiple data tables open

I like this solution a lot as it's all in one window. However, is there any way to make this sort of display in a JMP table window where the user can save the file, rather than in a window? 

 

 

Re: Multiple data tables open

Hi @matt7109,

The menu and toolbars you see are limited to one per window. You will need to create your own custom behaviors for actions (like save) that would typically be done using the menu or toolbars. 

The below script creates a red triangle menu that will save the data table within the Outline Box. Notice that I turned on the "Data Table List" in the toolbar so that you can see the current data table. With this method, you can still use the menus (Tables, DOE, Analyze, Graph) that will perform actions on the current data table shown in the data table list.

 

Names Default To Here( 1 );
// open the tables as private
dt1 = Open( "$SAMPLE_DATA\Big Class.jmp", private );
dt2 = Open( "$SAMPLE_DATA\Bands Data.jmp", private );

// Create a function to create each data table to reduce code redundancy
getDataTableOutlineBox = Function( {dt},
	Eval(
		Eval Expr(
			Outline Box( dt << Get Name, // title of the tab
				dt << New Data Box(), //DataBrowserBox
				// Add scripts to the Red Triangle menu for the Outline Box
				<<Set Menu Script(
					{
						"Save As", // Name of the menu item script
						
						// get path to save the data table
						savePath = Pick File(
							"Save JMP Data Table",
							"",
							{"JMP Files|jmp", "All Files|*"},
							1,
							1,
							Expr( dt << get name ) || ".jmp" // evaluate the name of the table when the menu script is added
						);
						// If the user selected a path, save the table at that path
						If( savePath != "",
							Expr( dt ) << save( savePath )
						); 
					
					}
				)
			)
		)
	)
);

// (optional) Turn on the Data Table list for reports so that you can see what the current data table is
Set Toolbar Visibility( "Data Table List", Report, true );

// Create a window with both tables shown
New Window( "Both Tables",
	Suppress AutoHide( 1 ), // Suppress the auto hide so that the toolbars appear
	<<OnClose(
		Try( Close( dt1, NoSave ) );
		Try( Close( dt2, NoSave ) );
	),
	H Splitter Box(
		size( 1200, 800 ),
		getDataTableOutlineBox( dt1 ),
		getDataTableOutlineBox( dt2 ),

	)
);

Below is a screenshot of the window after clicking on the Red Triangle Menu. 

2017-07-13_12-44-55.png

 

Justin
matt7109
Level III

Re: Multiple data tables open

This is perfect!! Thank you so much !