<?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 determine if a data table is already opened? in Discussions</title>
    <link>https://community.jmp.com/t5/Discussions/How-to-determine-if-a-data-table-is-already-opened/m-p/48#M48</link>
    <description>&lt;P&gt;You can loop through all the open tables by passing a number to Data Table() and compare names.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;tableIsOpen = Function( {tname},
	{rv = 0, i},
	For( i = 1, i &amp;lt; N Table() + 1 &amp;amp; rv == 0, i++,
		If( Lowercase( Data Table( i ) &amp;lt;&amp;lt; Get Name ) == Lowercase( tname ),
			rv = 1
		)
	);
	rv;
);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;edit: with a "&amp;lt;=" option&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;tableIsOpen = Function( {tname},
	{rv = 0, i},
	For( i = 1, i &amp;lt;= N Table() &amp;amp; rv == 0, i++,
		If( Lowercase( Data Table( i ) &amp;lt;&amp;lt; Get Name ) == Lowercase( tname ),
			rv = 1
		)
	);
	rv;
);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;BR /&gt;(The forum software really doesn't like less than or equal, which is why I use plain less than and added 1.)&lt;/P&gt;</description>
    <pubDate>Sun, 22 Jul 2018 23:44:31 GMT</pubDate>
    <dc:creator>XanGregg</dc:creator>
    <dc:date>2018-07-22T23:44:31Z</dc:date>
    <item>
      <title>How to determine if a data table is already opened?</title>
      <link>https://community.jmp.com/t5/Discussions/How-to-determine-if-a-data-table-is-already-opened/m-p/47#M47</link>
      <description>&lt;P&gt;This is how I used to do it before JMP 8:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;tableIsOpen = Function( {tname},
	{dt, rv = 0},
	Try(
		dt = Data Table( tname );
		rv = 1;
	);
	rv;
);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;BR /&gt;This does not work in JMP verison 8 because DataTable function will open a file dialog if the table is not opened already. User can always press "cancel" but it's annoying.&lt;BR /&gt;&lt;BR /&gt;Thanks for any help.&lt;BR /&gt;Tommy&lt;/P&gt;</description>
      <pubDate>Sun, 22 Jul 2018 23:42:24 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/How-to-determine-if-a-data-table-is-already-opened/m-p/47#M47</guid>
      <dc:creator>tommst</dc:creator>
      <dc:date>2018-07-22T23:42:24Z</dc:date>
    </item>
    <item>
      <title>Re: How to determine if a data table is already opened?</title>
      <link>https://community.jmp.com/t5/Discussions/How-to-determine-if-a-data-table-is-already-opened/m-p/48#M48</link>
      <description>&lt;P&gt;You can loop through all the open tables by passing a number to Data Table() and compare names.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;tableIsOpen = Function( {tname},
	{rv = 0, i},
	For( i = 1, i &amp;lt; N Table() + 1 &amp;amp; rv == 0, i++,
		If( Lowercase( Data Table( i ) &amp;lt;&amp;lt; Get Name ) == Lowercase( tname ),
			rv = 1
		)
	);
	rv;
);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;edit: with a "&amp;lt;=" option&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;tableIsOpen = Function( {tname},
	{rv = 0, i},
	For( i = 1, i &amp;lt;= N Table() &amp;amp; rv == 0, i++,
		If( Lowercase( Data Table( i ) &amp;lt;&amp;lt; Get Name ) == Lowercase( tname ),
			rv = 1
		)
	);
	rv;
);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;BR /&gt;(The forum software really doesn't like less than or equal, which is why I use plain less than and added 1.)&lt;/P&gt;</description>
      <pubDate>Sun, 22 Jul 2018 23:44:31 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/How-to-determine-if-a-data-table-is-already-opened/m-p/48#M48</guid>
      <dc:creator>XanGregg</dc:creator>
      <dc:date>2018-07-22T23:44:31Z</dc:date>
    </item>
    <item>
      <title>Re: How to determine if a data table is already opened?</title>
      <link>https://community.jmp.com/t5/Discussions/How-to-determine-if-a-data-table-is-already-opened/m-p/49#M49</link>
      <description>Thanks for the code.  I'm trying it out now.&lt;BR /&gt;I wish there's a more straight forward way of checking for opened data file.</description>
      <pubDate>Mon, 02 Mar 2009 16:41:44 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/How-to-determine-if-a-data-table-is-already-opened/m-p/49#M49</guid>
      <dc:creator>tommst</dc:creator>
      <dc:date>2009-03-02T16:41:44Z</dc:date>
    </item>
    <item>
      <title>Re: How to determine if a data table is already opened?</title>
      <link>https://community.jmp.com/t5/Discussions/How-to-determine-if-a-data-table-is-already-opened/m-p/877978#M104083</link>
      <description>&lt;P&gt;Came across this thread looking for something similar for closing lingering open data tables at the beginning of my script while testing code, instead of counting them. Used a combo of the code posted here and in another thread. Thought I'd post in case it's useful for anyone coming across this thread:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;// list of table names that I want to make sure are closed before running the script
tname = { "TABLE1", "TABLE2", "TABLE3", "TABLE4" };

// loop to see if open tables match the name in the list above, then close them
// need to restart the i counter to i = 0 because it seems closing a table changes the 'i' number associated with the table
For( i = 1, i &amp;lt;= N Table(), i++,

	If( N Rows (Loc( tname, Data Table(i) &amp;lt;&amp;lt; Get Name ) ) &amp;gt; 0, 
		Close(Data Table(i), no save);
		i = 0;
	)
);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 03 Jun 2025 17:37:59 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/How-to-determine-if-a-data-table-is-already-opened/m-p/877978#M104083</guid>
      <dc:creator>Plotasaurus</dc:creator>
      <dc:date>2025-06-03T17:37:59Z</dc:date>
    </item>
    <item>
      <title>Re: How to determine if a data table is already opened?</title>
      <link>https://community.jmp.com/t5/Discussions/How-to-determine-if-a-data-table-is-already-opened/m-p/877992#M104084</link>
      <description>&lt;P&gt;I would simplify the closing by using the Try() function&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Names Default To Here( 1 );

tname = {"TABLE1", "TABLE2", "TABLE3", "TABLE4"};

For Each( {dt}, tname,
	Try( Close( data table( dt ), nosave ) )
);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 03 Jun 2025 18:30:06 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/How-to-determine-if-a-data-table-is-already-opened/m-p/877992#M104084</guid>
      <dc:creator>txnelson</dc:creator>
      <dc:date>2025-06-03T18:30:06Z</dc:date>
    </item>
  </channel>
</rss>

