<?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 do I get the returned variable of my function to be assigned to my new variable? in Discussions</title>
    <link>https://community.jmp.com/t5/Discussions/How-do-I-get-the-returned-variable-of-my-function-to-be-assigned/m-p/232100#M46044</link>
    <description>&lt;P&gt;What is returned to the calling statement is the last item processed in the function, so all you should have to do is to place the handle you are calling the new data table as the last item, and it will return it to the calling variable.&amp;nbsp; See the simple example below&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Names Default To Here( 1 );
dt = Open( "$SAMPLE_DATA/big class.jmp" );
dt2 = New Table( "lookup",
	New Column( "Sex", character, values( {"F", "M"} ) ),
	New Column( "Avg Height", values( {68, 70} ) )
);

joinTables = Function( {x1, x2, m1},{},
	dtFinal = x1 &amp;lt;&amp;lt; join( With( x2 ), Merge same name columns(1), Match Columns( Column( m1 ) == Column( m1 ) ) );
	dtFinal;
);

dtSlopeTable=joinTables(dt,dt2,"Sex");

show(dtSlopeTable);&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Tue, 05 Nov 2019 02:56:02 GMT</pubDate>
    <dc:creator>txnelson</dc:creator>
    <dc:date>2019-11-05T02:56:02Z</dc:date>
    <item>
      <title>How do I get the returned variable of my function to be assigned to my new variable?</title>
      <link>https://community.jmp.com/t5/Discussions/How-do-I-get-the-returned-variable-of-my-function-to-be-assigned/m-p/232076#M46038</link>
      <description>&lt;P&gt;I have created and tested a function called JoinTables. This function will return a data table. I would like the returned datatable to be assigned to the dtSlopeTable variable.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;	dtSlopeTable = JoinTables(dataTableList, columnGroup);
	&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;When I run this, the output table is created with the desired content but it is not associated with the variable name "dtSlopeTable".&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;When I check the value of dtSlopeTable, it says&amp;nbsp;Data Table( "UnknownTable" ).&lt;BR /&gt;I have tried wait(0) and wait(10) but niether work.&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;However, I am able to get it working if I use wait(0) and the line before has:&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;dtTest = New table();&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This is a weird work around and I would perfer to use a clean solution. Do you have an idea of why I can't assign the table to the variable name?&lt;BR /&gt;If you need to view the function definition, I would be happy to attach.&lt;BR /&gt;&lt;BR /&gt;Thanks for the help.&lt;/P&gt;</description>
      <pubDate>Tue, 05 Nov 2019 01:46:45 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/How-do-I-get-the-returned-variable-of-my-function-to-be-assigned/m-p/232076#M46038</guid>
      <dc:creator>Kelly</dc:creator>
      <dc:date>2019-11-05T01:46:45Z</dc:date>
    </item>
    <item>
      <title>Re: How do I get the returned variable of my function to be assigned to my new variable?</title>
      <link>https://community.jmp.com/t5/Discussions/How-do-I-get-the-returned-variable-of-my-function-to-be-assigned/m-p/232100#M46044</link>
      <description>&lt;P&gt;What is returned to the calling statement is the last item processed in the function, so all you should have to do is to place the handle you are calling the new data table as the last item, and it will return it to the calling variable.&amp;nbsp; See the simple example below&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Names Default To Here( 1 );
dt = Open( "$SAMPLE_DATA/big class.jmp" );
dt2 = New Table( "lookup",
	New Column( "Sex", character, values( {"F", "M"} ) ),
	New Column( "Avg Height", values( {68, 70} ) )
);

joinTables = Function( {x1, x2, m1},{},
	dtFinal = x1 &amp;lt;&amp;lt; join( With( x2 ), Merge same name columns(1), Match Columns( Column( m1 ) == Column( m1 ) ) );
	dtFinal;
);

dtSlopeTable=joinTables(dt,dt2,"Sex");

show(dtSlopeTable);&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 05 Nov 2019 02:56:02 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/How-do-I-get-the-returned-variable-of-my-function-to-be-assigned/m-p/232100#M46044</guid>
      <dc:creator>txnelson</dc:creator>
      <dc:date>2019-11-05T02:56:02Z</dc:date>
    </item>
  </channel>
</rss>

