cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Check out the JMP® Marketplace featured Capability Explorer add-in
Choose Language Hide Translation Bar
ninanoc
Level I

Delete multiple table opened with certain string

Hi

 

I'm really bad with coding. I have a script where it opens multiple subset of tables, appends it and creates a control chart. The problem is that multiple subtables are created and left opened.

 

All table name starts with the string "subset". How can I close all tables at once?

 

1 ACCEPTED SOLUTION

Accepted Solutions
txnelson
Super User

Re: Delete multiple table opened with certain string

Here is a simple piece of code that will delete the subsets

Names Default To Here( 1 );
numTables = N Table();
For( t = numTables, t >= 1, t--,
	tName = Data Table( t ) << get name;
	Show( t, tname );
	If( Left( tName, 6 ) == "Subset",
		Close( Data Table( tName ), nosave )
	);
);
Jim

View solution in original post

2 REPLIES 2
jthi
Super User

Re: Delete multiple table opened with certain string

I would suggest closing the data tables immediately after they are not needed with Close(datatablereference, No Save), but it will require most likely a bit more scripting to add those to correct locations.

 

So here is a script to which should close all datatables starting with subset:

Names Default To Here(1);

tableList = Get Data Table List(); //get names of all tables

for(i = 1, i <= N Items(tableList), i++,
	//get name of current table in list
	currentTableName = tableList[i] << Get Name; 
	//check if table starts with subset. Use Lowercase() to take care of different way of naming "subset"
	isSubsetTable = Starts With(Lowercase(currentTableName), "subset"); 
	If(isSubsetTable,
		Try(
			Close(tableList[i], no save);
			Print("Closed data table: " || currentTableName ||"."),
			show(exception_msg)); //try to close
	);
);
-Jarmo
txnelson
Super User

Re: Delete multiple table opened with certain string

Here is a simple piece of code that will delete the subsets

Names Default To Here( 1 );
numTables = N Table();
For( t = numTables, t >= 1, t--,
	tName = Data Table( t ) << get name;
	Show( t, tname );
	If( Left( tName, 6 ) == "Subset",
		Close( Data Table( tName ), nosave )
	);
);
Jim