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

Data Table On Close Issue depending on how it is closed

Hello, I am having an issue with how JMP decides to close the data tables that have the following script:
 
dt << On Close(close(Current Data Table(),nosave));
 
My main issue is how the data tables close when there are multiple windows open with this script. If the X in the top right corner is used it will work perfectly 10/10 times, but if you go down to the taskbar and hover over each table and hit X then it can close multiple data tables (usually data tables that have been opened after the one that is being closed) which can cause problems if we are actively using other tables.
 
Is the Current Data Table being carried throughout the other data tables? I was trying to find some way to move away from the Current Data Table approach and have it grab the current name of the data table and attempt to close it that way but I was having issues.

 

Is this an issue with the script or an issue with JMP's handling of closing windows through the taskbar?

 

Thanks,

2 ACCEPTED SOLUTIONS

Accepted Solutions
Craige_Hales
Super User

Re: Data Table On Close Issue depending on how it is closed

Don't use CurrentDataTable(). Ever, if it can be avoided. As you noticed, the current table is set by clicking on a table, and some other possibilities. Apparently the task bar does not count as clicking on the table.

I think you are trying to apply the 'nosave' to forget any changes. (you could also use the setDirty(0) function.) Here's two ways to do it.

First, with a 'this' parameter, a in this example. It holds a window that has a child box that that knows the table.

dt = Open( "$sample_data/big class.jmp" );
dt << onclose(
	Function( {a},
		Close( (a << child) << getdatatable, nosave );
		1;
	)
);

Second, by baking in the table:

dt = Open( "$sample_data/big class.jmp" );
Eval(
	Eval Expr(
		dt << onclose(
			Close( Expr( dt ), nosave );
			1;
		)
	)
);

 

Craige

View solution in original post

Craige_Hales
Super User

Re: Data Table On Close Issue depending on how it is closed

The setdirty example:

dt = Open( "$sample_data/big class.jmp" );
Eval(
	Eval Expr(
		dt << onclose(
			Expr( dt ) << setdirty( 0 );
			1;
		)
	)
);

If that is your goal, this might be slightly more correct; JMP's internals won't be surprised when the onclose script returns and the table is already closed. For this one, the 1; that is returned signals JMP to continue closing the table.

Craige

View solution in original post

9 REPLIES 9
jthi
Super User

Re: Data Table On Close Issue depending on how it is closed

Which data tables are you trying to close with On Close()?

-Jarmo
ralphtedesco
Level II

Re: Data Table On Close Issue depending on how it is closed

Data Tables that are pulling information from another data source (LIMS, Excel, etc).

 

It pulls the information and then there are scripts that automatically generate IR charts, applies control limits to the columns and a few other small conveniences.

 

I try and make things as automated as possible in the design of the scripts and there should be minimal human interference with the data table. Anything that we need to look at basically jumps out at you and will indicate if action is needed to be taken. 

 

Since these are pulling from a read-only view of LIMS/Excel, there is no reason to need anything to be saved except for in rare circumstances where additional manipulation is needed.

Craige_Hales
Super User

Re: Data Table On Close Issue depending on how it is closed

Don't use CurrentDataTable(). Ever, if it can be avoided. As you noticed, the current table is set by clicking on a table, and some other possibilities. Apparently the task bar does not count as clicking on the table.

I think you are trying to apply the 'nosave' to forget any changes. (you could also use the setDirty(0) function.) Here's two ways to do it.

First, with a 'this' parameter, a in this example. It holds a window that has a child box that that knows the table.

dt = Open( "$sample_data/big class.jmp" );
dt << onclose(
	Function( {a},
		Close( (a << child) << getdatatable, nosave );
		1;
	)
);

Second, by baking in the table:

dt = Open( "$sample_data/big class.jmp" );
Eval(
	Eval Expr(
		dt << onclose(
			Close( Expr( dt ), nosave );
			1;
		)
	)
);

 

Craige
Craige_Hales
Super User

Re: Data Table On Close Issue depending on how it is closed

The setdirty example:

dt = Open( "$sample_data/big class.jmp" );
Eval(
	Eval Expr(
		dt << onclose(
			Expr( dt ) << setdirty( 0 );
			1;
		)
	)
);

If that is your goal, this might be slightly more correct; JMP's internals won't be surprised when the onclose script returns and the table is already closed. For this one, the 1; that is returned signals JMP to continue closing the table.

Craige
ralphtedesco
Level II

Re: Data Table On Close Issue depending on how it is closed

This does the job so far! If I come across any situations that it goes awry I will come on back.

 

Thanks Craige!

ralphtedesco
Level II

Re: Data Table On Close Issue depending on how it is closed

Hello Craige, one small hiccup has arisen with the Set Dirty approach.

 

With the Current Data Table method it would also close any open windows that were dependent on the data table being open such as a control chart. What would be the best approach to force it to close any dependent windows so that it would close the entire data table in one click and no other prompts?

 

Edit: 

Eval(
	Eval Expr(
		dt << onclose(
			Close( Expr( dt ), nosave );
			1;
		)
	)
);

 This one works for closing any dependent windows. I hadn't tried it! Thank you for your help everyone.

jthi
Super User

Re: Data Table On Close Issue depending on how it is closed

Have you tried the other options (using Close) @Craige_Hales suggested (not using << Set Dirty). I think they should work even if you have reports open. Other option would be to get list of all reports associated with the data table and close those first (not sure if there is any easy function for this).

-Jarmo
ralphtedesco
Level II

Re: Data Table On Close Issue depending on how it is closed

Hello Jarmo,

 

I just tried one of the other examples Craige had set forth and it did end up working. I really need to look at all the answers given before responding back in the future. It is easy to forget that there are a million ways to do the same thing in JMP and all of the feedback here helps remind me of that.

 

Thank you for your help.

hogi
Level XI

Re: Data Table On Close Issue depending on how it is closed

It seems that the onClose option doesn't get saved with the data table.

Is there  a possibility to store the onClose setting with the data table?

 

If not, is there a possibility to execute the OnClose message lisently when the data table is opened by the user?

 

I tried to put  

dt << on close(	Function( {a}, Close( (a << child) << getdatatable, nosave );	1;));

into my On Open Table Script, but now whenever I open the data table, Jmp shows the warning:

hogi_0-1707079757287.png

 

Hm, scheduling a script

- big words for "tell Jmp at the end to do nothing, not even save the data"