<?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: ThisDataTable() ? in Discussions</title>
    <link>https://community.jmp.com/t5/Discussions/ThisDataTable/m-p/705263#M88977</link>
    <description>&lt;P&gt;Looks convincing :)&lt;/img&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;STRIKE&gt;So, when running a table script, the current data table is automatically mapped to the table with the script.&lt;/STRIKE&gt;&lt;BR /&gt;&lt;STRIKE&gt;So, this is the reason why &lt;STRONG&gt;&lt;EM&gt;a&amp;nbsp;script in a data table [...] sends messages to the data table that encloses the script.&lt;/EM&gt;&lt;/STRONG&gt;&lt;/STRIKE&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;automatically: yes&lt;/P&gt;&lt;P&gt;immediately: no&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;see below:&lt;/P&gt;</description>
    <pubDate>Sun, 16 Jun 2024 19:58:49 GMT</pubDate>
    <dc:creator>hogi</dc:creator>
    <dc:date>2024-06-16T19:58:49Z</dc:date>
    <item>
      <title>ThisDataTable() ?</title>
      <link>https://community.jmp.com/t5/Discussions/ThisDataTable/m-p/705074#M88951</link>
      <description>&lt;P&gt;For Columns and Objects like Reports, there exists&amp;nbsp; a command&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;obj &amp;lt;&amp;lt; Get Data Table();&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;to get a reference to the respective data table.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Is there a similar function for&amp;nbsp;Table Scripts? something like&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;This Data Table()&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;some lazy implementations which could lead to issues:&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;reference the data table by its name.&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;Data Table ("my table") &amp;lt;&amp;lt; new column("test")&lt;/FONT&gt;&lt;BR /&gt;this works till there is a conflict with another data table with the same name and " 2" is added automatically to the table name.&lt;/LI&gt;&lt;LI&gt;&lt;FONT face="courier new,courier"&gt;&lt;FONT face="arial,helvetica,sans-serif"&gt;use &lt;/FONT&gt;mydt = current data table()&lt;/FONT&gt;&amp;nbsp;to generate a reference to the data table&lt;BR /&gt;This works fine if I run the script from the table itself. To have the chance to click on the play button, one has to select the data table. Therefore, it will be the current one. good.&lt;BR /&gt;&lt;U&gt;But when I trigger the Table Script via &lt;FONT face="courier new,courier"&gt;dt &amp;lt;&amp;lt; run sricpt ("myscript")&lt;/FONT&gt;, another data table could be the current one.&lt;/U&gt;&lt;STRIKE&gt;&lt;BR /&gt;&lt;/STRIKE&gt;edit #1:&amp;nbsp;&lt;a href="https://community.jmp.com/t5/user/viewprofilepage/user-id/14366"&gt;@jthi&lt;/a&gt;'s example below suggests, that this statement is not correct:&lt;BR /&gt;When you trigger a table script, the table with the table script gets the &lt;FONT face="courier new,courier"&gt;current data table&lt;/FONT&gt;.&lt;BR /&gt;so: no issues.&lt;BR /&gt;edit #2: ... but it seems that "&lt;EM&gt;gets the &lt;FONT face="courier new,courier"&gt;current data table&lt;/FONT&gt;&lt;/EM&gt;" doesn't happen &lt;EM&gt;immediately&lt;/EM&gt;.&amp;nbsp;&lt;BR /&gt;so: under some circumstances there could be some issues (see below)&lt;/LI&gt;&lt;/UL&gt;</description>
      <pubDate>Sun, 16 Jun 2024 20:24:23 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/ThisDataTable/m-p/705074#M88951</guid>
      <dc:creator>hogi</dc:creator>
      <dc:date>2024-06-16T20:24:23Z</dc:date>
    </item>
    <item>
      <title>Re: ThisDataTable() ?</title>
      <link>https://community.jmp.com/t5/Discussions/ThisDataTable/m-p/705148#M88962</link>
      <description>&lt;P&gt;It sounds a little convoluted, but&lt;/P&gt;
&lt;OL&gt;
&lt;LI&gt;I believe that a script in a data table implicitly sends messages to the data table that encloses the script. So explicitly referring to the data table using "current data table" is unnecessary.&lt;/LI&gt;
&lt;LI&gt;If you run a script inside of a data table from out side of the data table, you must obtain the handle of the data table first, such that you can send Run Script("script name") to the data table. The data table can be the current or not, which does not matter.&lt;/LI&gt;
&lt;/OL&gt;
&lt;P&gt;So, I guess that the answer is that there is no need to use anything, in a script, to refer to the data table that encloses the script. Remove "dt = current data table()" from your script and see how it goes. I guess there are some other reasons why you need that line, but maybe there is a different solution to address that problem.&lt;/P&gt;</description>
      <pubDate>Sun, 03 Dec 2023 03:11:07 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/ThisDataTable/m-p/705148#M88962</guid>
      <dc:creator>peng_liu</dc:creator>
      <dc:date>2023-12-03T03:11:07Z</dc:date>
    </item>
    <item>
      <title>Re: ThisDataTable() ?</title>
      <link>https://community.jmp.com/t5/Discussions/ThisDataTable/m-p/705171#M88967</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://community.jmp.com/t5/user/viewprofilepage/user-id/2781"&gt;@peng_liu&lt;/a&gt;&amp;nbsp;wrote:&lt;OL&gt;&lt;LI&gt;I believe that a script in a data table implicitly sends messages to the data table that encloses the script.&lt;/LI&gt;&lt;/OL&gt;&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;Thanks.&amp;nbsp;interesting, good to now.&lt;/P&gt;&lt;P&gt;To be honest, a bit of a freaky feeling to remove all those&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;dt &amp;lt;&amp;lt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;FONT face="courier new,courier"&gt;&amp;nbsp;&lt;/FONT&gt;&amp;nbsp;They gave me some peace of mind that the script was doing exactly what it was supposed to do. I believe it works without ...&lt;/P&gt;&lt;P&gt;Even&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Nrows(&lt;STRIKE&gt;dt&lt;/STRIKE&gt;);&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;seems to work.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 03 Dec 2023 08:32:08 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/ThisDataTable/m-p/705171#M88967</guid>
      <dc:creator>hogi</dc:creator>
      <dc:date>2023-12-03T08:32:08Z</dc:date>
    </item>
    <item>
      <title>Re: ThisDataTable() ?</title>
      <link>https://community.jmp.com/t5/Discussions/ThisDataTable/m-p/705219#M88973</link>
      <description>&lt;BLOCKQUOTE&gt;
&lt;P&gt;dt = current data table() in the table script:&lt;BR /&gt;This works fine if I run the script from the table itself. To have the chance to click on the play button, one has to select the data table. Therefore, it will be the current one. good.&lt;BR /&gt;But when I trigger the Table Script via JSL, another data table could be the current one.&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Have you verified this to be the case if you run it via JSL? If I remember correctly I have been running some of my more complicated table scripts just fine through JSL, without needing to worry about correcting the current data table (I might remember wrong though).&lt;/P&gt;
&lt;LI-SPOILER&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Names Default To Here(1);

dt3 = New Table("table with script",
	Add Rows(2),
	Compress File When Saved(1),
	New Script(
		"test", JSL Quote(Local Here(
dt = Current Data Table();
dt &amp;lt;&amp;lt; Graph Builder(
	Size(528, 454),
	Show Control Panel(0),
	Variables(X(:Column 1), Y(:Column 2)),
	Elements(Points(X, Y, Legend(3)), Smoother(X, Y, Legend(4)))
);
show(dt);
);
)	,
		As String(1)
	),
	New Column("Column 1", Numeric, "Continuous", Format("Best", 12), Set Values([1, 2])),
	New Column("Column 2", Numeric, "Continuous", Format("Best", 12), Set Values([2, 3]))
);

dt2 = New Table("current table",
	Add Rows(0),
	Compress File When Saved(1),
	New Column("Column 1", Numeric, "Continuous", Format("Best", 12), Set Values([])),
	New Column("Column 2", Numeric, "Continuous", Format("Best", 12), Set Values([]))
);

Current Data Table(dt2);
Wait(1);
Show(Current Data Table());
dt3 &amp;lt;&amp;lt; Run Script("test");
Show(Current Data Table());

&lt;/CODE&gt;&lt;/PRE&gt;
&lt;/LI-SPOILER&gt;</description>
      <pubDate>Sun, 03 Dec 2023 12:22:54 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/ThisDataTable/m-p/705219#M88973</guid>
      <dc:creator>jthi</dc:creator>
      <dc:date>2023-12-03T12:22:54Z</dc:date>
    </item>
    <item>
      <title>Re: ThisDataTable() ?</title>
      <link>https://community.jmp.com/t5/Discussions/ThisDataTable/m-p/705263#M88977</link>
      <description>&lt;P&gt;Looks convincing :)&lt;/img&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;STRIKE&gt;So, when running a table script, the current data table is automatically mapped to the table with the script.&lt;/STRIKE&gt;&lt;BR /&gt;&lt;STRIKE&gt;So, this is the reason why &lt;STRONG&gt;&lt;EM&gt;a&amp;nbsp;script in a data table [...] sends messages to the data table that encloses the script.&lt;/EM&gt;&lt;/STRONG&gt;&lt;/STRIKE&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;automatically: yes&lt;/P&gt;&lt;P&gt;immediately: no&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;see below:&lt;/P&gt;</description>
      <pubDate>Sun, 16 Jun 2024 19:58:49 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/ThisDataTable/m-p/705263#M88977</guid>
      <dc:creator>hogi</dc:creator>
      <dc:date>2024-06-16T19:58:49Z</dc:date>
    </item>
    <item>
      <title>Re: ThisDataTable() ?</title>
      <link>https://community.jmp.com/t5/Discussions/ThisDataTable/m-p/766181#M94617</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I could replicate my error from 2023 and have new findings:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The problem:&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;a jsl script triggers&amp;nbsp;&lt;FONT face="courier new,courier"&gt;dt &amp;lt;&amp;lt; run script(myScript)&lt;/FONT&gt;&lt;/LI&gt;&lt;LI&gt;&lt;FONT face="courier new,courier"&gt;myscript&lt;/FONT&gt; starts with&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;mydt = current data table();&lt;/FONT&gt;&lt;/LI&gt;&lt;LI&gt;my original assumption: &lt;EM&gt;when I trigger the Table Script via JSL, another data table could be the current one.&lt;BR /&gt;&lt;/EM&gt;seems to hold for some cases -&amp;nbsp; today I could generate such a case where&lt;/LI&gt;&lt;/UL&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;mydt = current data table();
mydt &amp;lt;&amp;lt; new column ("test1"); // was sent to the wrong data table
new column("test2"); // was sent to THIS DATA TABLE&amp;nbsp;(fits to Peng&amp;nbsp;Liu's&amp;nbsp;post)&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;So:&lt;BR /&gt;If you plan to run a Table script via&amp;nbsp;&lt;FONT face="courier new,courier"&gt;dt &amp;lt;&amp;lt; run script(myScript)&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;and need a reference to&lt;FONT face="courier new,courier"&gt; ThisDataTable,&lt;/FONT&gt; add &lt;FONT face="courier new,courier"&gt;wait(0)&lt;/FONT&gt; to be on the safe side:&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;wait(0); // !!!!
thisDataTable = current data table();&lt;BR /&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;BR /&gt;similar findings, but with slightly different context :&amp;nbsp;&lt;LI-MESSAGE title="run table script" uid="754736" url="https://community.jmp.com/t5/Discussions/run-table-script/m-p/754736#U754736" discussion_style_icon_css="lia-mention-container-editor-message lia-img-icon-forum-thread lia-fa-icon lia-fa-forum lia-fa-thread lia-fa"&gt;&lt;/LI-MESSAGE&gt;&lt;/P&gt;</description>
      <pubDate>Sun, 16 Jun 2024 20:26:03 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/ThisDataTable/m-p/766181#M94617</guid>
      <dc:creator>hogi</dc:creator>
      <dc:date>2024-06-16T20:26:03Z</dc:date>
    </item>
  </channel>
</rss>

