cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Choose Language Hide Translation Bar
Djtjhin
Level IV

List box showing all open tables

I'm trying to build a listbox which lists down all the opened data table and gets updated automatically with newly opened / newly closed table. I've started with the script below but for some reason the onClose function doesn't work. 

Appreciate the help

names default to here(1);
f1 = function ({Temp_list},
	T_list = Temp_list << get name();
	lb << remove all;
	lb << append (T_list)
);

f2 = function ({Temp_list},
	T_list = Temp_list << get name();
	lb << remove all;
	lb << append (T_list)
);
asub = Subscribe to data table list( , onopen(f1));
Subscribe to data table list(asub , onclose(f2));

nw = new window("Trial",show menu(0),
	vlistbox(
		T_list = get data table list ();
		lb = listbox(T_list);
	)
);

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
jthi
Super User

Re: List box showing all open tables

You should just be able to add new values to lb and them remove just the closed one with index (using Contains() to get index) also added local variables to functions.

Names Default To Here(1);
f1 = function ({Temp_list}, {tableList},
	tableList = Temp_list << get name();
	lb << append (tableList)
);

f2 = function ({Temp_list}, {tableList},
	tableList = Temp_list << get name();
	lb << Remove Item(Contains(lb << get items, tableList));
);
asub = Subscribe to data table list( , onopen(f1));
Subscribe to data table list(asub , OnClose(f2));

nw = new window("Trial",show menu(0),
	vlistbox(
		lb = listbox(get data table list ());
	)
);
-Jarmo

View solution in original post

5 REPLIES 5
txnelson
Super User

Re: List box showing all open tables

Using the below JSL, here is what I have discovered.

Names Default To Here( 1 );
f2 = Function( {Temp_list},
	T_list = Get Data Table List();
	lb << remove all;
	lb << append( T_list );
	show("Close");
);
f1 = Function( {Temp_list},
	T_list = Get Data Table List();
	lb << remove all;
	lb << append( T_list );
	show("add");
);

asub = Subscribe to Data Table List( , onopen( f1 ) );
Subscribe to Data Table List(asub , onclose( f2 ) );

nw = New Window( "Trial",
	Show Menu( 0 ),
	V List Box(
		T_list = Get Data Table List();
		lb = List Box( T_list );
	)
);

 

  1. The created list box will Add new data tables without error.
    1. The f1 function is executed once for each addition
  2. If you close a data table, it will not be removed from the list box.
  3. If you close a second data table, the previous closed data table will be removed from the list box.
  4. If you close the list box and run the JSL for a second time, and close a data table, an f2 function will be run twice.  The f2 function from the first running of the JSL will be run, followed by the running of the second instance of the f2 function.  This can be shown by changing the Show() statement.  If the Show statement was changed from
    Show( "Close" );
    to
    Show( "Close 2" );

    upon closing a data table, both versions of the Show() statement will be displayed,

  5. Subsequent executions of the JSL add additional copies of the f2 function, with each copy being executed for each data table closing.
  6. Clear Globals and Clear Symbols does not eliminate the previous versions of the f2 function.

This is clearly a JMP bug and needs to be sent into the JMP Support Staff.

I have submitted the bug to them.

Jim
Djtjhin
Level IV

Re: List box showing all open tables

Thanks @txnelson !! That's exactly the bug which I encountered. I guess in the meantime I'll have to find a workaround for this. 

jthi
Super User

Re: List box showing all open tables

You should just be able to add new values to lb and them remove just the closed one with index (using Contains() to get index) also added local variables to functions.

Names Default To Here(1);
f1 = function ({Temp_list}, {tableList},
	tableList = Temp_list << get name();
	lb << append (tableList)
);

f2 = function ({Temp_list}, {tableList},
	tableList = Temp_list << get name();
	lb << Remove Item(Contains(lb << get items, tableList));
);
asub = Subscribe to data table list( , onopen(f1));
Subscribe to data table list(asub , OnClose(f2));

nw = new window("Trial",show menu(0),
	vlistbox(
		lb = listbox(get data table list ());
	)
);
-Jarmo
Djtjhin
Level IV

Re: List box showing all open tables

Thanks @jthi ! That works!

If you don't mind, could you also show how you would set up the "OnRename" clause as well ?

jthi
Super User

Re: List box showing all open tables

After testing Subscribe to data table list a bit more, I would avoid it if possible. It doesn't seem to work well at all, events not triggering, fairly bad documentation on how it should be used and so on. I'm using JMP16.1.0 Pro on Windows 10.

 

I have one application where I would like to have something like this, but I think I will just add Refresh datatable list or something similar.

-Jarmo