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.
Choose Language Hide Translation Bar
jmp13
Level I

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

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!

 

 

1 REPLY 1
ian_jmp
Staff

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

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

NamesDefaultToHere(1);

// 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));
	);
	matchingTables;
	);

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