BookmarkSubscribeSubscribe to RSS Feed
mjoner

Community Trekker

Joined:

Jun 23, 2011

Interactively closing a data table while script in progress

If reports are open and a user attempts to close a data table, JMP (by default) asks what to do: "The data table "Big Class.jmp" has other windows open. You can close all windows for this data table, or just hide it instead."

 

Nice feature, really. I'd like to work it in to a script I'm creating. I have identified the data table I want to work with. I then open a window with New Window() that collects a bunch of information about that data table, and eventually offers an "OK" or "Cancel" type option. But if the user interactively closes the data before closing out the script, strange things happen... especially if the user comes back and tries "OK" with a now-closed Data Table.

 

Is there a way to hook in to JMP's sensing of whether a report is still open? How is it done?

2 ACCEPTED SOLUTIONS

Accepted Solutions
Jeff_Perkinson

Community Manager

Joined:

Jun 23, 2011

Solution

Re: Interactively closing a data table while script in progress

Try the Subscribe message for a data table. That will set up the relationship that triggers that message.

 

Names Default To Here( 1 );
dt = Open( "$SAMPLE_DATA/Big Class.jmp" );
my_win=new window("My summary",
vlistbox( 
	Text Box("Avg height: " || char(col mean( :height))),
	Text Box("Avg weight: " || char(col mean( :weight))) 
));
dt << Subscribe(
	"name1"("client"),
	On Close(  New Window( "Closing Data Table" , 
		Text Box("You're closing Big Class")
	) )
);
-Jeff
Highlighted
mjoner

Community Trekker

Joined:

Jun 23, 2011

Solution

Re: Interactively closing a data table while script in progress

Thank you. I didn't know about the "client" keyword that triggers the message. I did have to modify the code a bit to remove the trigger if the script's window is closed before someone attempts to close the data table. That was straightforward enough, though.

Here is what I ended up with:

Names Default To Here( 1 );
dt = Open( "$SAMPLE_DATA/Big Class.jmp" );
my_win=new window("My summary",
vlistbox( 
	Text Box("Avg height: " || char(col mean( :height))),
	Text Box("Avg weight: " || char(col mean( :weight))) 
));
my_win << On Close(dt << Unsubscribe("name1", On Close));
dt << Subscribe(
	"name1"("client"),
	On Close( my_win << Close window )
);
2 REPLIES
Jeff_Perkinson

Community Manager

Joined:

Jun 23, 2011

Solution

Re: Interactively closing a data table while script in progress

Try the Subscribe message for a data table. That will set up the relationship that triggers that message.

 

Names Default To Here( 1 );
dt = Open( "$SAMPLE_DATA/Big Class.jmp" );
my_win=new window("My summary",
vlistbox( 
	Text Box("Avg height: " || char(col mean( :height))),
	Text Box("Avg weight: " || char(col mean( :weight))) 
));
dt << Subscribe(
	"name1"("client"),
	On Close(  New Window( "Closing Data Table" , 
		Text Box("You're closing Big Class")
	) )
);
-Jeff
Highlighted
mjoner

Community Trekker

Joined:

Jun 23, 2011

Solution

Re: Interactively closing a data table while script in progress

Thank you. I didn't know about the "client" keyword that triggers the message. I did have to modify the code a bit to remove the trigger if the script's window is closed before someone attempts to close the data table. That was straightforward enough, though.

Here is what I ended up with:

Names Default To Here( 1 );
dt = Open( "$SAMPLE_DATA/Big Class.jmp" );
my_win=new window("My summary",
vlistbox( 
	Text Box("Avg height: " || char(col mean( :height))),
	Text Box("Avg weight: " || char(col mean( :weight))) 
));
my_win << On Close(dt << Unsubscribe("name1", On Close));
dt << Subscribe(
	"name1"("client"),
	On Close( my_win << Close window )
);