Staff (Retired)

Close Data Table when Report Closes


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.


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 ) ) ),
// 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" ) ) ) );
Capture.PNGPlatform with <<OnClose event attached


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

Article Labels
Article Tags