For the latest version of JMP Help, visit JMP.com/help.


Scripting Guide > Data Tables > Basic Data Table Scripting > Perform Actions on All Open Data Tables
Publication date: 06/21/2023

Perform Actions on All Open Data Tables

Using JSL, to perform an action on all of the data tables that are currently open (except private tables), use N Table() to get a list of references to each one:

dt1 = Open( "$SAMPLE_DATA/Cities.jmp" );
dt2 = Open( "$SAMPLE_DATA/Big Class.jmp" );
openDTs = List();
For( i = 1, i <= N Table(), i++,
	Insert Into( openDTs, Data Table( i ) );
);

openDTs now is a list of references to all open data tables. You can send messages to any one by using openDTs(n). You can use a for loop to send messages to all of the open data tables. This loop adds a new column named My Column to each open data table.

For( i = 1, i <= N Items( openDTs ), i++,
	openDTs[i] << New Column( "My Column" );
);

If you just want a list of table names and not references, use the Get Name message:

For( i = 1, i <= N Table(), i++,
	Insert Into( openDTs, Data Table( i ) << Get Name());
	);

You can then use the list of table names to put the names of all of the open data tables in a list box (window) so that the user can choose and perform tables operations. Or, you can write the names out to a file.

Want more information? Have questions? Get answers in the JMP User Community (community.jmp.com).