<?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: How to get reference to a table within &amp;quot;On Close&amp;quot; in that table? in Discussions</title>
    <link>https://community.jmp.com/t5/Discussions/How-to-get-reference-to-a-table-within-quot-On-Close-quot-in/m-p/918823#M107818</link>
    <description>&lt;P&gt;Usually I just evaluate the table name/reference to the On Close. You can also use &amp;lt;&amp;lt;On Close(Function({this})) and &lt;EM&gt;this&lt;/EM&gt; will be reference to the data table &lt;STRONG&gt;window&lt;/STRONG&gt; (script index has example of this).&amp;nbsp;&lt;/P&gt;
&lt;LI-SPOILER&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Names Default To Here(1);

data = New Namespace(
	"DataTables"
);
gui = New Namespace(
	"GUI"
);

data:tablesListAA = [=&amp;gt; ];
gui:guiWindow = Expr(
	Border Box(Left(10), Right(10), Top(10), Bottom(10), Sides(15),
		V List Box(
			gui:cb = Combo Box(
				{},
				selection = gui:cb &amp;lt;&amp;lt; GetSelected();
				Print("Selected: " || selection);
				Current Data Table(data:tablesListAA[selection]);
				Print("Current Data Table: " || (Current Data Table() &amp;lt;&amp;lt; Get Name));
			), 
	
			Button Box("Add Table",
				filePath = Pick File("Select JMP File", "$SAMPLE_DATA", {"JMP Files|jmp;jsl;jrn", "All Files|*"}, 1, 0, "newJmpFile.jmp");
				dt = Open(filePath);
				Eval(
					Eval Expr(
						dt &amp;lt;&amp;lt; On Close(
							tb = Expr(dt);
							_tableName = tb &amp;lt;&amp;lt; get name;
							Print("Trying to remove: " || _tableName);
						)
					)
				);
				
				dtName = dt &amp;lt;&amp;lt; Get Name();
				Insert Into(data:tablesListAA, dtName, dt);
				gui:cb &amp;lt;&amp;lt; Set Items(data:tablesListAA &amp;lt;&amp;lt; Get Keys);
			
			)

		)
	)
);

nw = New Window("Test table selection", gui:guiWindow);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;/LI-SPOILER&gt;
&lt;P&gt;You might also consider using Subscribe To Data Table List() to keep track of the tables. I have used that to build something very similar to the table list you see for example on top of JMP's script editor and it is able to handle namechanges/table closures/opens (it is more complicated to build and does have its issues).&lt;/P&gt;</description>
    <pubDate>Wed, 10 Dec 2025 19:24:16 GMT</pubDate>
    <dc:creator>jthi</dc:creator>
    <dc:date>2025-12-10T19:24:16Z</dc:date>
    <item>
      <title>How to get reference to a table within "On Close" in that table?</title>
      <link>https://community.jmp.com/t5/Discussions/How-to-get-reference-to-a-table-within-quot-On-Close-quot-in/m-p/918808#M107816</link>
      <description>&lt;P&gt;Hi!&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I need some help with getting a reference to the table within On Close statement of that said table.&lt;/P&gt;
&lt;P&gt;I have a simple script: GUI with "Open" button, that opens a data table, and a combo box with list of tables.&lt;/P&gt;
&lt;P&gt;I also keep track of the tables in an associative array with table names as keys and table references as values.&lt;/P&gt;
&lt;P&gt;I have a couple of legacy namespaces that I have to maintain in this script. In order to remove table from the the combo box I use this Eval(Eval Expr(Expr())) trick in OnClose statement. However, this trick doesn't work with removing table from Associative Array.&lt;/P&gt;
&lt;P&gt;There is another trick with Function({this}, _dt =&amp;nbsp;((this &amp;lt;&amp;lt; Child) &amp;lt;&amp;lt; Get Data Table)). It works correctly with getting the reference to data table, but stops working when I place it within Eval(Eval Expr(Expr()))).&lt;/P&gt;
&lt;P&gt;I tried to get the reference to the table separately, but looks like I don't know how Function({this}, &amp;lt;script&amp;gt;) works. How do I assign a result of this function to a variable?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Anyways, here's the latest iteration of my script, please help me tweak it to make it work.&lt;/P&gt;
&lt;P&gt;Eventually, I will need to handle data table manual name changes somehow and reflect it in the combo box.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Names Default To Here( 1 );

data = New Namespace(
	"DataTables"
);
gui = New Namespace(
	"GUI"
);

data:tablesListAA = [=&amp;gt; ];
gui:guiWindow = Expr(
	Border Box( Left( 10 ), Right( 10 ), Top( 10 ), Bottom( 10 ), Sides( 15 ),
		V List Box(
			gui:cb = Combo Box(
				{},
				selection = gui:cb &amp;lt;&amp;lt; GetSelected();
				Print( "Selected: " || selection );
				Current Data Table( data:tablesListAA[selection] );
				Print( "Current Data Table: " || (Current Data Table() &amp;lt;&amp;lt; Get Name) );
			), 
	
			Button Box( "Add Table",
				filePath = Pick File(
					"Select JMP File",
					"$SAMPLE_DATA",
					{"JMP Files|jmp;jsl;jrn", "All Files|*"},
					1,
					0,
					"newJmpFile.jmp"
				);
				dt = Open( filePath );
				Eval(
					Eval Expr(
						dt &amp;lt;&amp;lt; On Close(
							getTable = Function( {this},
										_table = ((this &amp;lt;&amp;lt; Child) &amp;lt;&amp;lt; Get Data Table);
										Return(_table);
									);
							_table = getTable(this);
							Local( {data = Namespace( Expr( data &amp;lt;&amp;lt; Get Name ) ), gui = Namespace( Expr( gui &amp;lt;&amp;lt; Get Name ) ), _table = Expr(_table)},
								Try(
										_tableName = _table &amp;lt;&amp;lt; Get Name;
										Print("Trying to remove: "||_tableName);
										Remove From( data:tablesListAA, _tableName );
										gui:cb &amp;lt;&amp;lt; Set Items( data:tablesListAA &amp;lt;&amp;lt; Get Keys );
									
								)
							)
						)
					)
				);
				

				dtName = dt &amp;lt;&amp;lt; Get Name();
				Insert Into( data:tablesListAA, dtName, dt );
				gui:cb &amp;lt;&amp;lt; Set Items( data:tablesListAA &amp;lt;&amp;lt; Get Keys );
			
			)

		)
	)
	
);

nw = New Window( "Test table selection", gui:guiWindow );
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 10 Dec 2025 19:02:18 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/How-to-get-reference-to-a-table-within-quot-On-Close-quot-in/m-p/918808#M107816</guid>
      <dc:creator>miguello</dc:creator>
      <dc:date>2025-12-10T19:02:18Z</dc:date>
    </item>
    <item>
      <title>Re: How to get reference to a table within "On Close" in that table?</title>
      <link>https://community.jmp.com/t5/Discussions/How-to-get-reference-to-a-table-within-quot-On-Close-quot-in/m-p/918823#M107818</link>
      <description>&lt;P&gt;Usually I just evaluate the table name/reference to the On Close. You can also use &amp;lt;&amp;lt;On Close(Function({this})) and &lt;EM&gt;this&lt;/EM&gt; will be reference to the data table &lt;STRONG&gt;window&lt;/STRONG&gt; (script index has example of this).&amp;nbsp;&lt;/P&gt;
&lt;LI-SPOILER&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Names Default To Here(1);

data = New Namespace(
	"DataTables"
);
gui = New Namespace(
	"GUI"
);

data:tablesListAA = [=&amp;gt; ];
gui:guiWindow = Expr(
	Border Box(Left(10), Right(10), Top(10), Bottom(10), Sides(15),
		V List Box(
			gui:cb = Combo Box(
				{},
				selection = gui:cb &amp;lt;&amp;lt; GetSelected();
				Print("Selected: " || selection);
				Current Data Table(data:tablesListAA[selection]);
				Print("Current Data Table: " || (Current Data Table() &amp;lt;&amp;lt; Get Name));
			), 
	
			Button Box("Add Table",
				filePath = Pick File("Select JMP File", "$SAMPLE_DATA", {"JMP Files|jmp;jsl;jrn", "All Files|*"}, 1, 0, "newJmpFile.jmp");
				dt = Open(filePath);
				Eval(
					Eval Expr(
						dt &amp;lt;&amp;lt; On Close(
							tb = Expr(dt);
							_tableName = tb &amp;lt;&amp;lt; get name;
							Print("Trying to remove: " || _tableName);
						)
					)
				);
				
				dtName = dt &amp;lt;&amp;lt; Get Name();
				Insert Into(data:tablesListAA, dtName, dt);
				gui:cb &amp;lt;&amp;lt; Set Items(data:tablesListAA &amp;lt;&amp;lt; Get Keys);
			
			)

		)
	)
);

nw = New Window("Test table selection", gui:guiWindow);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;/LI-SPOILER&gt;
&lt;P&gt;You might also consider using Subscribe To Data Table List() to keep track of the tables. I have used that to build something very similar to the table list you see for example on top of JMP's script editor and it is able to handle namechanges/table closures/opens (it is more complicated to build and does have its issues).&lt;/P&gt;</description>
      <pubDate>Wed, 10 Dec 2025 19:24:16 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/How-to-get-reference-to-a-table-within-quot-On-Close-quot-in/m-p/918823#M107818</guid>
      <dc:creator>jthi</dc:creator>
      <dc:date>2025-12-10T19:24:16Z</dc:date>
    </item>
    <item>
      <title>Re: How to get reference to a table within "On Close" in that table?</title>
      <link>https://community.jmp.com/t5/Discussions/How-to-get-reference-to-a-table-within-quot-On-Close-quot-in/m-p/918848#M107820</link>
      <description>&lt;P&gt;For some reason I decided that baking in table into Eval(Eval Expr(Excpr))) was wrong for this use case. LEt me try to re-write it again.&lt;/P&gt;</description>
      <pubDate>Wed, 10 Dec 2025 21:28:46 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/How-to-get-reference-to-a-table-within-quot-On-Close-quot-in/m-p/918848#M107820</guid>
      <dc:creator>miguello</dc:creator>
      <dc:date>2025-12-10T21:28:46Z</dc:date>
    </item>
  </channel>
</rss>

