<?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 reference a table variable inside a table variable in Discussions</title>
    <link>https://community.jmp.com/t5/Discussions/How-to-reference-a-table-variable-inside-a-table-variable/m-p/257398#M50577</link>
    <description>&lt;P&gt;A Table Variable is just a saved string of characters.&amp;nbsp; Even if your value of QQ would have worked, your IF statement could never be true.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;if ( dt:TT == 51, show("success"), show("didn't quite work"));&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;dt:TT can never have the value of 51.&amp;nbsp; All table variables end up as character strings, so the IF statement was ever going to work, it would have to be written as:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;if ( dt:TT == "51", show("success"), show("didn't quite work"));&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Here is the documentation from the Scripting Guide&lt;/P&gt;
&lt;PRE&gt;&lt;STRONG&gt;Table Variables&lt;/STRONG&gt;
Table variables are for storing a single text string value, such as “Notes”. To understand how
variables work, first get its existing value by sending a Get Table Variable message:
	dt = Open( "$SAMPLE_DATA/Solubility.jmp" );
	dt &amp;lt;&amp;lt; Get Table Variable( "Notes" );
		"Chemical compounds were measured for solubility in different solvents. This
		table shows the log of the partition coefficient (logP) of 72 organic
		solutes in 6 aqueous/nonpolar systems."
Now change the existing value of the string using Set Table Variable and then use Get
Table Variable again to check that the string has been updated:
	dt &amp;lt;&amp;lt; Set Table Variable( "Notes", "Solubility of chemical compounds" );
	dt &amp;lt;&amp;lt; Get Table Variable( "Notes" );
		"Solubility of chemical compounds"
The following example adds two new table variables to a data table:
	dt = Open( "$DOCUMENTS/Big Class.jmp" );
	myvar = "This is my version of the JMP Big Class sample data.";
	dt &amp;lt;&amp;lt; Set Table Variable( "key1", myvar );
	dt &amp;lt;&amp;lt; Set Table Variable( "key2", myvar );
Notice that setting the value creates a new variable only if one by the given name does not
already exist. If you add two table variables with the same name, only one variable is created.&lt;/PRE&gt;
&lt;P&gt;You could possibly do what you want using a Table Script, but you would have to first set the table variable QQ and then run the table script that would update TT&lt;/P&gt;</description>
    <pubDate>Fri, 10 Apr 2020 23:25:31 GMT</pubDate>
    <dc:creator>txnelson</dc:creator>
    <dc:date>2020-04-10T23:25:31Z</dc:date>
    <item>
      <title>How to reference a table variable inside a table variable</title>
      <link>https://community.jmp.com/t5/Discussions/How-to-reference-a-table-variable-inside-a-table-variable/m-p/257381#M50573</link>
      <description>&lt;P&gt;After creating the first two variables, I'd like to make my angleRefY and my angleRefX variables be offset from zeroX and zeroY by a static number. I've tried to do this a few different ways as you can see below.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="MarkJohnson_0-1586552035759.png" style="width: 400px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/22942i2543573BDF2DD36A/image-size/medium?v=v2&amp;amp;px=400" role="button" title="MarkJohnson_0-1586552035759.png" alt="MarkJohnson_0-1586552035759.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The only way that produced a number was this script, but then the variable becomes 6 instead of QQ+1, so they still aren't linked.&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;dt &amp;lt;&amp;lt; Set Table Variable("TT", dt:QQ + 1);&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Does anyone know how this could be done? Ideally zeroX = some number, zeroY = some number, angleRefX = zeroX + some number, and angleRefY = zeroY + some number as a dynamic reference.&lt;/P&gt;</description>
      <pubDate>Fri, 10 Apr 2020 20:57:50 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/How-to-reference-a-table-variable-inside-a-table-variable/m-p/257381#M50573</guid>
      <dc:creator>MarkJohnson</dc:creator>
      <dc:date>2020-04-10T20:57:50Z</dc:date>
    </item>
    <item>
      <title>Re: How to reference a table variable inside a table variable</title>
      <link>https://community.jmp.com/t5/Discussions/How-to-reference-a-table-variable-inside-a-table-variable/m-p/257388#M50574</link>
      <description>&lt;P&gt;Here is a simple example.&amp;nbsp; Your code was close, just needed to understand that all Table Variables are character, and also, all you need to do to reference a table variable is to use :QQ, since the dt is already the object of the message.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;names default to here(1);
dt=new table("Example", add rows(3),new column("Sample", values([1,2,3])));
dt &amp;lt;&amp;lt; new table variable("QQ", 42 );
dt &amp;lt;&amp;lt; New Table Variable("TT", num(:QQ) + 1);&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 10 Apr 2020 21:21:32 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/How-to-reference-a-table-variable-inside-a-table-variable/m-p/257388#M50574</guid>
      <dc:creator>txnelson</dc:creator>
      <dc:date>2020-04-10T21:21:32Z</dc:date>
    </item>
    <item>
      <title>Re: How to reference a table variable inside a table variable</title>
      <link>https://community.jmp.com/t5/Discussions/How-to-reference-a-table-variable-inside-a-table-variable/m-p/257393#M50576</link>
      <description>&lt;P&gt;That creates a static offset, I should have been more clear that the goal is a dynamic offset. For example, if QQ gets reassigned to 43, the goal is to have TT resolve to 44 all by itself.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here is an adaptation of your code that should print whether the variable is actually dynamic or not.&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;names default to here(1);
dt=new table("Example", add rows(3),new column("Sample", values([1,2,3])));
dt &amp;lt;&amp;lt; new table variable("QQ", 42 );
dt &amp;lt;&amp;lt; New Table Variable("TT", eval(num(:QQ) + 1));
wait(0);
dt &amp;lt;&amp;lt; set table variable("QQ", 50);
if ( dt:TT == 51, show("success"), show("didn't quite work"));&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 10 Apr 2020 22:13:35 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/How-to-reference-a-table-variable-inside-a-table-variable/m-p/257393#M50576</guid>
      <dc:creator>MarkJohnson</dc:creator>
      <dc:date>2020-04-10T22:13:35Z</dc:date>
    </item>
    <item>
      <title>Re: How to reference a table variable inside a table variable</title>
      <link>https://community.jmp.com/t5/Discussions/How-to-reference-a-table-variable-inside-a-table-variable/m-p/257398#M50577</link>
      <description>&lt;P&gt;A Table Variable is just a saved string of characters.&amp;nbsp; Even if your value of QQ would have worked, your IF statement could never be true.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;if ( dt:TT == 51, show("success"), show("didn't quite work"));&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;dt:TT can never have the value of 51.&amp;nbsp; All table variables end up as character strings, so the IF statement was ever going to work, it would have to be written as:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;if ( dt:TT == "51", show("success"), show("didn't quite work"));&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Here is the documentation from the Scripting Guide&lt;/P&gt;
&lt;PRE&gt;&lt;STRONG&gt;Table Variables&lt;/STRONG&gt;
Table variables are for storing a single text string value, such as “Notes”. To understand how
variables work, first get its existing value by sending a Get Table Variable message:
	dt = Open( "$SAMPLE_DATA/Solubility.jmp" );
	dt &amp;lt;&amp;lt; Get Table Variable( "Notes" );
		"Chemical compounds were measured for solubility in different solvents. This
		table shows the log of the partition coefficient (logP) of 72 organic
		solutes in 6 aqueous/nonpolar systems."
Now change the existing value of the string using Set Table Variable and then use Get
Table Variable again to check that the string has been updated:
	dt &amp;lt;&amp;lt; Set Table Variable( "Notes", "Solubility of chemical compounds" );
	dt &amp;lt;&amp;lt; Get Table Variable( "Notes" );
		"Solubility of chemical compounds"
The following example adds two new table variables to a data table:
	dt = Open( "$DOCUMENTS/Big Class.jmp" );
	myvar = "This is my version of the JMP Big Class sample data.";
	dt &amp;lt;&amp;lt; Set Table Variable( "key1", myvar );
	dt &amp;lt;&amp;lt; Set Table Variable( "key2", myvar );
Notice that setting the value creates a new variable only if one by the given name does not
already exist. If you add two table variables with the same name, only one variable is created.&lt;/PRE&gt;
&lt;P&gt;You could possibly do what you want using a Table Script, but you would have to first set the table variable QQ and then run the table script that would update TT&lt;/P&gt;</description>
      <pubDate>Fri, 10 Apr 2020 23:25:31 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/How-to-reference-a-table-variable-inside-a-table-variable/m-p/257398#M50577</guid>
      <dc:creator>txnelson</dc:creator>
      <dc:date>2020-04-10T23:25:31Z</dc:date>
    </item>
    <item>
      <title>Re: How to reference a table variable inside a table variable</title>
      <link>https://community.jmp.com/t5/Discussions/How-to-reference-a-table-variable-inside-a-table-variable/m-p/257636#M50632</link>
      <description>&lt;P&gt;Jim,&lt;/P&gt;
&lt;P&gt;Thanks for that tip on table variables being character. That's a definite, pull your hair out if you don't know it, problem to run into.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;one other little addition.&amp;nbsp; if,&amp;nbsp; dt:QQ="51";&amp;nbsp; then wrapping dt:QQ, like this, num(dt:QQ) will return 51 rather than "51". But if dt:QQ isn't numeric, then it will return missing.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The alternative to this, which will work,&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;if ( dt:TT == "51", show("success"), show("didn't quite work"));&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;is something like this, which will work if dt:TT is numeric&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;if ( num( dt:TT ) == 51, show("success"), show("didn't quite work"));&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 13 Apr 2020 12:36:58 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/How-to-reference-a-table-variable-inside-a-table-variable/m-p/257636#M50632</guid>
      <dc:creator>Byron_JMP</dc:creator>
      <dc:date>2020-04-13T12:36:58Z</dc:date>
    </item>
    <item>
      <title>Re: How to reference a table variable inside a table variable</title>
      <link>https://community.jmp.com/t5/Discussions/How-to-reference-a-table-variable-inside-a-table-variable/m-p/257666#M50636</link>
      <description>Well there ya go. If it only can store string values, it seems pretty clear that I won't be able to have it be a dynamic reference. Running the table script makes sense. It is just one extra click too, not bad. Thank you for the help!!</description>
      <pubDate>Mon, 13 Apr 2020 14:12:48 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/How-to-reference-a-table-variable-inside-a-table-variable/m-p/257666#M50636</guid>
      <dc:creator>MarkJohnson</dc:creator>
      <dc:date>2020-04-13T14:12:48Z</dc:date>
    </item>
    <item>
      <title>Re: How to reference a table variable inside a table variable</title>
      <link>https://community.jmp.com/t5/Discussions/How-to-reference-a-table-variable-inside-a-table-variable/m-p/257872#M50671</link>
      <description>&lt;P&gt;you could always just throw the variable into the global name space and reference that.&lt;/P&gt;</description>
      <pubDate>Tue, 14 Apr 2020 13:13:53 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/How-to-reference-a-table-variable-inside-a-table-variable/m-p/257872#M50671</guid>
      <dc:creator>Byron_JMP</dc:creator>
      <dc:date>2020-04-14T13:13:53Z</dc:date>
    </item>
  </channel>
</rss>

