Today I am trying to close all but a select number of data tables as a repeating procedure is run using Data Table Name variables. I have three tables. One where results are collected, one where invalid results of the first table are collected, and one that the user opens for the script to know what ID values to use to compare. I found a Discussion where tables can be closed (it has been included in my script here), but it uses quoted text in a list for the table names. Since my users will be choosing a different data table for each iteration for the third table, how can I use a data table name variable to include it in the list and leave it open at the end of processing?
DontClose = {CompareTable, CollectionTable, IDTable}; // Example names of tables you want to leave open
//CompareTable = "Validation Table"
//Collection Table = "Unmatched Values"
//IDTable = could be anything but I want to leave this open once the processing loop is completed
// Loop backwards through the list, so the table numbers do not change
For( i = N Table(), i > 0, i--,
print( Data Table(i) << Get Name ) ;
If( Contains( DontClose, Data Table( i ) << get name ),
Continue(),
Close( Data Table( i ), "No Save" )
)
);
Here's an approach that allows you to use the data table references:
Names Default To Here( 1 );
dt = Open( "$SAMPLE_DATA/Big Class.jmp" );
dt2 = Open( "$SAMPLE_DATA/Fitness.jmp" );
dt3 = Open( Pick File( "Select File", "$DOCUMENTS" ) );
dontClose = Eval List( {dt, dt2, dt3} );
Show( dontClose );
// Loop backwards through the list, so the table numbers do not change
For( i = N Table(), i > 0, i--,
If( Contains( DontClose, Data Table( i ) ),
Continue(),
Close( Data Table( i ), "No Save" )
)
);
Hope that helps!
Hello,
You can also set one table variable on each jmp datatable :
dt << Set Table Variable("ToClose","N");
Then you can loop and check the value :
For( i = N Table(), i > 0, i--,
vtoclose = Data Table(i) << Get Table Variable ("ToClose") ;
If ( Contains(vtoclose,"Y") >=1 ,
Close(Data Table(i),NoSave),
print("ToClose is not set to Y : do not close")
);
);
@guillaumebugnon I see that ALL tables would need that variable set. The script I am writing opens and generates a multitude of tables so this would add a step that I feel is best left for less intense purposes. What I ultimately wish to do is have a list of IDs (could be over 200) and have the script run a process to produce at least 75 summarizations for each ID. Although this will work, it seems Wendy Murphrey's solution is just right for my application.
Thank you for taking the time to help with my dilemma!
Here's an approach that allows you to use the data table references:
Names Default To Here( 1 );
dt = Open( "$SAMPLE_DATA/Big Class.jmp" );
dt2 = Open( "$SAMPLE_DATA/Fitness.jmp" );
dt3 = Open( Pick File( "Select File", "$DOCUMENTS" ) );
dontClose = Eval List( {dt, dt2, dt3} );
Show( dontClose );
// Loop backwards through the list, so the table numbers do not change
For( i = N Table(), i > 0, i--,
If( Contains( DontClose, Data Table( i ) ),
Continue(),
Close( Data Table( i ), "No Save" )
)
);
Hope that helps!
@Wendy_Murphrey This is the ticket! Works just like I need. Since this script can open or produce hundreds of tables, this is perfect for my needs.
Thank you, thank you, thank you! I learn something new every day in JSL!
Can you post your script?
Closing tables that have linked Summary tables will automatically close the Summary table.
Since you generate all of the data tables to be destroyed, why not insert each table reference into a list as it is created? You can then iterate over the list when it is time to close them.