<?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 return a data_table from a FUNCTION ? in Discussions</title>
    <link>https://community.jmp.com/t5/Discussions/How-to-return-a-data-table-from-a-FUNCTION/m-p/8315#M8309</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello&lt;/P&gt;&lt;P&gt;PMroz,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;thank you for answering so quickly !&lt;/P&gt;&lt;P&gt;It is indeed a little bit special, but one get used ... :)&lt;/img&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I tried in the mean time and when I did a Summary(all rows), or a similar "transparent" function, it works also.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I got a mistake when I was having at the last line:&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;current data table(dt);&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Now I understand that actually what is returned, is the "output" of current data table, which is probably ".", so that was probably my mistake. Is that right?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;What happens with Open files in local functions after one returns to the main program? Apparently the table stays open, although it is "local" ?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;BR,&lt;/P&gt;&lt;P&gt;Alex&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Mon, 07 Apr 2014 18:40:44 GMT</pubDate>
    <dc:creator>alex_sas</dc:creator>
    <dc:date>2014-04-07T18:40:44Z</dc:date>
    <item>
      <title>How to return a data_table from a FUNCTION ?</title>
      <link>https://community.jmp.com/t5/Discussions/How-to-return-a-data-table-from-a-FUNCTION/m-p/8313#M8307</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;script&lt;BR /&gt;Hi,&lt;/P&gt;&lt;P&gt;I'm a relatively new user of JMP/SAS scripting language, and only used to other "standard" languages like C, VBA, PASCAL,&amp;nbsp; etc... so maybe my question is obvious...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I can't figure out how to return cleanly the TABLE result from a function.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If I don't use the DEFAULT LOCAL option, of course the table returns if I use the name of the table int he FUNCTION, but when I try to do something like&lt;/P&gt;&lt;P&gt;d_result= MyFunction(Input1,Input2;Input3);&amp;nbsp;&amp;nbsp;&amp;nbsp; the variable&amp;nbsp; d_result is "."&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I would like to use the {Default LOCAL} option in order to program cleanly and avoid problem with LOCAL/GLOBAL variables, so hence I would like to output the table.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;In general I don't understand how to specify the returning results of a FUNCTION.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I tried with RETURN() in the input params, but it seems only to work with a simple parameter (numer or string), not a table (see Page 212 of JSL Syntax reference):&lt;/P&gt;&lt;P&gt;Function({arguments}, &amp;lt;{local variables}&amp;gt;, &amp;lt;Return(&amp;lt;expr&amp;gt;)&amp;gt;, script)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks a lot for your help !!!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Best regards.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Alex&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 07 Apr 2014 16:18:02 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/How-to-return-a-data-table-from-a-FUNCTION/m-p/8313#M8307</guid>
      <dc:creator>alex_sas</dc:creator>
      <dc:date>2014-04-07T16:18:02Z</dc:date>
    </item>
    <item>
      <title>Re: How to return a data_table from a FUNCTION ?</title>
      <link>https://community.jmp.com/t5/Discussions/How-to-return-a-data-table-from-a-FUNCTION/m-p/8314#M8308</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;JMP functions don't use a return statement.&amp;nbsp; Rather, the last expression that is evaluated is the one that's returned.&amp;nbsp; Here's a simple example:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: green;"&gt;//------------------------------------------------------------------------------&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: green;"&gt;/*&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: green;"&gt;Function Name: get_table&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: green;"&gt;Description: Return a table identifier as selected by the user&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: green;"&gt;Arguments:&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-size: 10pt; line-height: 1.5em;"&gt;&lt;SPAN style="color: #008000; font-family: 'Courier New';"&gt;(none)&lt;/SPAN&gt; &lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: green;"&gt;*/&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black;"&gt;get_table &lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: navy;"&gt;=&lt;/SPAN&gt; &lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: #0000dd;"&gt;Function&lt;/SPAN&gt;&lt;SPAN style="color: black; font-size: 10.0pt; font-family: 'Courier New';"&gt;&lt;STRONG&gt;(&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black;"&gt; &lt;STRONG&gt;{}&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: navy;"&gt;,&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;STRONG&gt;{&lt;/STRONG&gt;Default Local&lt;STRONG&gt;}&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: navy;"&gt;,&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black;"&gt; &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; dt &lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: navy;"&gt;=&lt;/SPAN&gt; &lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: #0000dd;"&gt;open&lt;/SPAN&gt;&lt;SPAN style="color: black; font-size: 10.0pt; font-family: 'Courier New';"&gt;&lt;STRONG&gt;()&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: navy;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; dt&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: navy;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="color: black; font-size: 10.0pt; font-family: 'Courier New';"&gt;&lt;STRONG&gt;)&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: navy;"&gt;;&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black;"&gt; &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: green;"&gt;// test it out&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black;"&gt;one_dt &lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: navy;"&gt;=&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black;"&gt; get_table&lt;STRONG&gt;()&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: navy;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: navy;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;Technically the line of the function with just "dt;" is redundant.&amp;nbsp; I left it in as an example.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 07 Apr 2014 18:04:13 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/How-to-return-a-data-table-from-a-FUNCTION/m-p/8314#M8308</guid>
      <dc:creator>pmroz</dc:creator>
      <dc:date>2014-04-07T18:04:13Z</dc:date>
    </item>
    <item>
      <title>Re: How to return a data_table from a FUNCTION ?</title>
      <link>https://community.jmp.com/t5/Discussions/How-to-return-a-data-table-from-a-FUNCTION/m-p/8315#M8309</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello&lt;/P&gt;&lt;P&gt;PMroz,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;thank you for answering so quickly !&lt;/P&gt;&lt;P&gt;It is indeed a little bit special, but one get used ... :)&lt;/img&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I tried in the mean time and when I did a Summary(all rows), or a similar "transparent" function, it works also.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I got a mistake when I was having at the last line:&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;current data table(dt);&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Now I understand that actually what is returned, is the "output" of current data table, which is probably ".", so that was probably my mistake. Is that right?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;What happens with Open files in local functions after one returns to the main program? Apparently the table stays open, although it is "local" ?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;BR,&lt;/P&gt;&lt;P&gt;Alex&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 07 Apr 2014 18:40:44 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/How-to-return-a-data-table-from-a-FUNCTION/m-p/8315#M8309</guid>
      <dc:creator>alex_sas</dc:creator>
      <dc:date>2014-04-07T18:40:44Z</dc:date>
    </item>
    <item>
      <title>Re: How to return a data_table from a FUNCTION ?</title>
      <link>https://community.jmp.com/t5/Discussions/How-to-return-a-data-table-from-a-FUNCTION/m-p/8316#M8310</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;The table stays open.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The variable &lt;STRONG&gt;dt&lt;/STRONG&gt;, which is used inside the function, is local and no longer has a value.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;In my example, the calling program uses the variable &lt;STRONG&gt;one_dt&lt;/STRONG&gt; to get the results from the function.&amp;nbsp; Therefore the variable &lt;STRONG&gt;one_dt&lt;/STRONG&gt; is visible to the calling program.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;When you supply an argument to &lt;STRONG&gt;current data table&lt;/STRONG&gt; [i.e. &lt;STRONG&gt;current data table(dt)&lt;/STRONG&gt;], it sets the current data table to whatever is pointing to &lt;STRONG&gt;dt&lt;/STRONG&gt;, and returns ".".&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 07 Apr 2014 19:06:41 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/How-to-return-a-data-table-from-a-FUNCTION/m-p/8316#M8310</guid>
      <dc:creator>pmroz</dc:creator>
      <dc:date>2014-04-07T19:06:41Z</dc:date>
    </item>
    <item>
      <title>Re: How to return a data_table from a FUNCTION ?</title>
      <link>https://community.jmp.com/t5/Discussions/How-to-return-a-data-table-from-a-FUNCTION/m-p/8317#M8311</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi PMRoz,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;thanks a lot for the clear explanations.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I wish this was explained somehwere clearly in the manuals :)&lt;/img&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Best regards,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Alex&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 08 Apr 2014 07:23:45 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/How-to-return-a-data-table-from-a-FUNCTION/m-p/8317#M8311</guid>
      <dc:creator>alex_sas</dc:creator>
      <dc:date>2014-04-08T07:23:45Z</dc:date>
    </item>
  </channel>
</rss>

