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.
Close Data Table when Report Closes

Problem

You've opened a table to show a report. The table might be temporary or invisible, and you want the table to go away silently when the report is closed.

Solution

Use the <<OnClose method to attach a script to the report. Make the script close the table.

// make a table
dt = New Table( "Temporary",
    Add Rows( 1e6 ),
    New Column( "x", Formula( Random Normal( 50, 30 ) ) ),
    New Column( "y", Formula( Random Normal( 50, 30 ) ) ),
    "Invisible"
);
// now make sure the formulas have finished evaluating
dt << RunFormulas;
// then clear the flag that says the table has changes that need to be saved
dt << SetDirty( 0 );
// finally, create a platform (or other window) with an OnClose script.
// the try() captures a message that might happen if the table is
// closed, causing the platform to close, causing the table to close...
dt << Bivariate( Y( :y ), X( :x ), <<OnClose( Try( Close( dt, "nosave" ) ) ) );
Platform with <<OnClose event attachedPlatform with <<OnClose event attached

Discussion

You can use the home window to make the invisible data table visible. The <<RunFormulas might be needed before the <<SetDirty(0) to make sure the background formula evaluation doesn't mark the table dirty, again. The "nosave" will prevent the prompt for the dirty table also, but not if the user closes the table instead of the report.

See Also

http://www.pega-analytics.co.uk/blog/housekeeping/

JSL Cookbook

If you’re looking for a code snippet or design pattern that performs a common task for your JSL project, the JSL Cookbook is for you.

This knowledge base contains building blocks of JSL code that you can use to reduce the amount of coding you have to do yourself.

It's also a great place to learn from the experts how to use JSL in new ways, with best practices.