Scripting Guide > Data Tables > Basic Data Table Scripting > Perform Actions on All Open Data Tables
发布日期: 08/07/2020

Perform Actions on All Open Data Tables

If you want 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.

需要更多信息?有问题?从 JMP 用户社区得到解答 (community.jmp.com).