Subscribe Bookmark RSS Feed

JSL: How to get retrieve names of more than one currently selected tables?


Community Member


Jul 16, 2017

Hi folks. I'm dealing with new tables every day (unique table names) which always have at least one common column header, which I use to Match Columns for Join. This is getting repetitive so I've been thinking of writing a script.


Problem: I don't want to have to specify both the table names in the script every time I want to Join two tables.


I'm looking for a method for the script to auto/semi-automatically pick the two tables I want to join. I know there is a method to retrieve the Currently Selected table, but what about the table Selected Before That? Best case is if there is a method to retrieve table names for all tables currently selected and then proceed to do Join for these tables.


Appreciate all ideas and advice! Thanks!






Jun 23, 2011

Of course there is only one 'current' table in a JMP session. But you could do something like this:


// Make some tables with different numbers of columns
n = 5;
for(t=1, t<=n, t++, NewTable("Table "||Char(t), << addMultipleColumns("Test", Random Integer(5), Character)));

// Function that returns the names of all open tables containing a specified column
tablesWithColumn =
Function({inCol}, {Default Local},
	matchingTables = {};
	for(t=1, t<=NTable(), t++,
		cols = DataTable(t) << getColumnNames("String");
		if(Contains(cols, inCol), InsertInto(matchingTables, DataTable(t) << getName));

// Try it out
myCol = "Test 3";
NewWindow("Open Tables with Column "||myCol, 
	PanelBox("Pick Tables to Join", 
		lb = ListBox(tablesWithColumn(myCol), maxSelected(2));