<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: List box showing all open tables in Discussions</title>
    <link>https://community.jmp.com/t5/Discussions/List-box-showing-all-open-tables/m-p/428187#M67754</link>
    <description>&lt;P&gt;Thanks&amp;nbsp;&lt;a href="https://community.jmp.com/t5/user/viewprofilepage/user-id/2687"&gt;@txnelson&lt;/a&gt;&amp;nbsp;!! That's exactly the bug which I encountered. I guess in the meantime I'll have to find a workaround for this.&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Tue, 19 Oct 2021 11:37:38 GMT</pubDate>
    <dc:creator>Djtjhin</dc:creator>
    <dc:date>2021-10-19T11:37:38Z</dc:date>
    <item>
      <title>List box showing all open tables</title>
      <link>https://community.jmp.com/t5/Discussions/List-box-showing-all-open-tables/m-p/428091#M67744</link>
      <description>&lt;P&gt;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.&amp;nbsp;&lt;/P&gt;&lt;P&gt;Appreciate the help :)&lt;/img&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=""&gt;names default to here(1);
f1 = function ({Temp_list},
	T_list = Temp_list &amp;lt;&amp;lt; get name();
	lb &amp;lt;&amp;lt; remove all;
	lb &amp;lt;&amp;lt; append (T_list)
);

f2 = function ({Temp_list},
	T_list = Temp_list &amp;lt;&amp;lt; get name();
	lb &amp;lt;&amp;lt; remove all;
	lb &amp;lt;&amp;lt; 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);
	)
);&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 09 Jun 2023 18:03:03 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/List-box-showing-all-open-tables/m-p/428091#M67744</guid>
      <dc:creator>Djtjhin</dc:creator>
      <dc:date>2023-06-09T18:03:03Z</dc:date>
    </item>
    <item>
      <title>Re: List box showing all open tables</title>
      <link>https://community.jmp.com/t5/Discussions/List-box-showing-all-open-tables/m-p/428164#M67750</link>
      <description>&lt;P&gt;Using the below JSL, here is what I have discovered.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Names Default To Here( 1 );
f2 = Function( {Temp_list},
	T_list = Get Data Table List();
	lb &amp;lt;&amp;lt; remove all;
	lb &amp;lt;&amp;lt; append( T_list );
	show("Close");
);
f1 = Function( {Temp_list},
	T_list = Get Data Table List();
	lb &amp;lt;&amp;lt; remove all;
	lb &amp;lt;&amp;lt; 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 );
	)
);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;OL&gt;
&lt;LI&gt;The created list box will Add new data tables without error.
&lt;OL&gt;
&lt;LI&gt;The f1 function is executed once for each addition&lt;/LI&gt;
&lt;/OL&gt;
&lt;/LI&gt;
&lt;LI&gt;If you close a data table, it will not be removed from the list box.&lt;/LI&gt;
&lt;LI&gt;If you close a second data table, the previous closed data table will be removed from the list box.&lt;/LI&gt;
&lt;LI&gt;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.&amp;nbsp; 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.&amp;nbsp; This can be shown by changing the Show() statement.&amp;nbsp; If the Show statement was changed from
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Show( "Close" );&lt;/CODE&gt;&lt;/PRE&gt;
to
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Show( "Close 2" );&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;upon closing a data table, both versions of the Show() statement will be displayed,&lt;/P&gt;
&lt;/LI&gt;
&lt;LI&gt;Subsequent executions of the JSL add additional copies of the f2 function, with each copy being executed for each data table closing.&lt;/LI&gt;
&lt;LI&gt;Clear Globals and Clear Symbols does not eliminate the previous versions of the f2 function.&lt;/LI&gt;
&lt;/OL&gt;
&lt;P&gt;This is clearly a JMP bug and needs to be sent into the JMP Support Staff.&lt;/P&gt;
&lt;P&gt;I have submitted the bug to them.&lt;/P&gt;</description>
      <pubDate>Tue, 19 Oct 2021 10:05:42 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/List-box-showing-all-open-tables/m-p/428164#M67750</guid>
      <dc:creator>txnelson</dc:creator>
      <dc:date>2021-10-19T10:05:42Z</dc:date>
    </item>
    <item>
      <title>Re: List box showing all open tables</title>
      <link>https://community.jmp.com/t5/Discussions/List-box-showing-all-open-tables/m-p/428187#M67754</link>
      <description>&lt;P&gt;Thanks&amp;nbsp;&lt;a href="https://community.jmp.com/t5/user/viewprofilepage/user-id/2687"&gt;@txnelson&lt;/a&gt;&amp;nbsp;!! That's exactly the bug which I encountered. I guess in the meantime I'll have to find a workaround for this.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 19 Oct 2021 11:37:38 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/List-box-showing-all-open-tables/m-p/428187#M67754</guid>
      <dc:creator>Djtjhin</dc:creator>
      <dc:date>2021-10-19T11:37:38Z</dc:date>
    </item>
    <item>
      <title>Re: List box showing all open tables</title>
      <link>https://community.jmp.com/t5/Discussions/List-box-showing-all-open-tables/m-p/428246#M67757</link>
      <description>&lt;P&gt;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.&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=""&gt;Names Default To Here(1);
f1 = function ({Temp_list}, {tableList},
	tableList = Temp_list &amp;lt;&amp;lt; get name();
	lb &amp;lt;&amp;lt; append (tableList)
);

f2 = function ({Temp_list}, {tableList},
	tableList = Temp_list &amp;lt;&amp;lt; get name();
	lb &amp;lt;&amp;lt; Remove Item(Contains(lb &amp;lt;&amp;lt; 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 ());
	)
);&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 19 Oct 2021 14:43:42 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/List-box-showing-all-open-tables/m-p/428246#M67757</guid>
      <dc:creator>jthi</dc:creator>
      <dc:date>2021-10-19T14:43:42Z</dc:date>
    </item>
    <item>
      <title>Re: List box showing all open tables</title>
      <link>https://community.jmp.com/t5/Discussions/List-box-showing-all-open-tables/m-p/428456#M67773</link>
      <description>&lt;P&gt;Thanks&amp;nbsp;&lt;a href="https://community.jmp.com/t5/user/viewprofilepage/user-id/14366"&gt;@jthi&lt;/a&gt;&amp;nbsp;! That works!&lt;/P&gt;&lt;P&gt;If you don't mind, could you also show how you would set up the "OnRename" clause as well ?&lt;/P&gt;</description>
      <pubDate>Wed, 20 Oct 2021 05:06:45 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/List-box-showing-all-open-tables/m-p/428456#M67773</guid>
      <dc:creator>Djtjhin</dc:creator>
      <dc:date>2021-10-20T05:06:45Z</dc:date>
    </item>
    <item>
      <title>Re: List box showing all open tables</title>
      <link>https://community.jmp.com/t5/Discussions/List-box-showing-all-open-tables/m-p/428465#M67777</link>
      <description>&lt;P&gt;After testing&amp;nbsp;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.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;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.&lt;/P&gt;</description>
      <pubDate>Wed, 20 Oct 2021 05:58:46 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/List-box-showing-all-open-tables/m-p/428465#M67777</guid>
      <dc:creator>jthi</dc:creator>
      <dc:date>2021-10-20T05:58:46Z</dc:date>
    </item>
    <item>
      <title>Re: List box showing all open tables</title>
      <link>https://community.jmp.com/t5/Discussions/List-box-showing-all-open-tables/m-p/845804#M102027</link>
      <description>&lt;P&gt;I'm bumping this topic with some new findings, maybe it will help someone. I was trying to do something similar as &lt;a href="https://community.jmp.com/t5/user/viewprofilepage/user-id/21450"&gt;@Djtjhin&lt;/a&gt;&amp;nbsp;and encountered all the same problems described here, which I mostly solved thanks to the discussion here.&lt;BR /&gt;What I can add is the explanation of the weird behavior described by &lt;a href="https://community.jmp.com/t5/user/viewprofilepage/user-id/2687"&gt;@txnelson&lt;/a&gt;. The issue is that if you subscribe without explicitly stating the subscription name as below:&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;asub = Subscribe to data table list( , OnOpen( Show("opening...") )&amp;nbsp;)&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;a new subscription under a new generic name ("_DTListSubscriber123") is created each time you run the script, increasing counter at the end.&lt;/P&gt;&lt;P&gt;The trick is either to explicitly name the subscriber so that you overwrite the same one each time you run the script, e.g.:&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;asub = Subscribe to data table list( "MyDTLSub1", OnOpen( Show("opening...") )&amp;nbsp;)&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;or to unsubscribe at the end, e.g. in the &amp;lt;&amp;lt;On Close statement of the window:&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Unsubscribe to data table list( asub, "ALL"&amp;nbsp;)&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;SPAN&gt;In other news, &lt;a href="https://community.jmp.com/t5/user/viewprofilepage/user-id/21450"&gt;@Djtjhin&lt;/a&gt;, for renaming it's works pretty simply, it seems the event is triggered AFTER renaming, so Get Data Table List() gets you the new name(s). But I was pulling my hair out from a different reason, &lt;SPAN&gt;before making it work,&amp;nbsp;due to lack of documentation&lt;/SPAN&gt;. In contrast to OnOpen and OnClose, the OnRename function needs 2 arguments (new and old name/table), otherwise you'll be getting errors. And although in this particular listbox example you don't actually need them, if you do, you also have to keep in mind they are of different variable type, one is a table, the other a string (see below).&lt;/SPAN&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Names Default To Here(1);

f = Function ( { new_name_as_table, old_name_as_string },
	print(asub||" renaming: "|| old_name_as_string || " to " || (new_name_as_table &amp;lt;&amp;lt; get name) );
	lb &amp;lt;&amp;lt; set items( Get Data table List() );
);

asub = Subscribe to data table list( "MySub", OnRename( f ) );

nw = new window("Trial",show menu(0),
	&amp;lt;&amp;lt; On Close(Unsubscribe to data table list( asub, "ALL")),
	vlistbox(
		lb = listbox(get data table list ());
	)
);

dt = Open( "$SAMPLE_DATA/Tiretread.jmp" );
dt &amp;lt;&amp;lt; set name( (dt&amp;lt;&amp;lt;get name) || "_renamed" );&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Otherwise I agree with general sentiment that the subscriber it's very hard to work with, you have to be really careful to tie up all the loose ends. Better documentation would be much appreciated.&lt;/P&gt;</description>
      <pubDate>Tue, 04 Mar 2025 10:04:00 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/List-box-showing-all-open-tables/m-p/845804#M102027</guid>
      <dc:creator>AlterEgo</dc:creator>
      <dc:date>2025-03-04T10:04:00Z</dc:date>
    </item>
  </channel>
</rss>

