<?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: Jump out of a function? in Discussions</title>
    <link>https://community.jmp.com/t5/Discussions/Jump-out-of-a-function/m-p/281988#M54572</link>
    <description>&lt;P&gt;Could you use &lt;STRONG&gt;return()&lt;/STRONG&gt;?&lt;/P&gt;</description>
    <pubDate>Sat, 25 Jul 2020 21:29:30 GMT</pubDate>
    <dc:creator>andrewtkarl</dc:creator>
    <dc:date>2020-07-25T21:29:30Z</dc:date>
    <item>
      <title>Jump out of a function?</title>
      <link>https://community.jmp.com/t5/Discussions/Jump-out-of-a-function/m-p/6132#M6131</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Is there a way to cleanly jump out of a function?&amp;nbsp; Something like the &lt;STRONG&gt;break()&lt;/STRONG&gt; function in a for loop.&amp;nbsp; I've tried &lt;STRONG&gt;throw()&lt;/STRONG&gt; but that stops the entire JSL script.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 02 Jan 2013 19:29:23 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Jump-out-of-a-function/m-p/6132#M6131</guid>
      <dc:creator>pmroz</dc:creator>
      <dc:date>2013-01-02T19:29:23Z</dc:date>
    </item>
    <item>
      <title>Re: Jump out of a function?</title>
      <link>https://community.jmp.com/t5/Discussions/Jump-out-of-a-function/m-p/6133#M6132</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I often enclose error prone expressions in Try() without Throw(). The placement of Try() – within the function or "around" the function call – depends if I only want to escape parts of the function or escape it completely in case of an exception. Throw() halts execution and I tend to use it mainly for debugging.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Compare these examples and their output:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="font-size: 12px; font-family: Courier; color: #008f00;"&gt;//Try() inside the function escapes chosen parts of function, script execution continues.&lt;/P&gt;&lt;P style="font-size: 12px; font-family: Courier;"&gt;exsqr &lt;SPAN style="color: #011993;"&gt;=&lt;/SPAN&gt; &lt;SPAN style="color: #032ce4;"&gt;Function&lt;/SPAN&gt;&lt;STRONG&gt;(&lt;/STRONG&gt; &lt;STRONG&gt;{&lt;/STRONG&gt;x&lt;STRONG&gt;}&lt;/STRONG&gt;&lt;SPAN style="color: #011993;"&gt;,&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 12px; font-family: Courier; color: #942193;"&gt;&lt;SPAN style="color: #000000;"&gt;&amp;nbsp; x2 &lt;/SPAN&gt;&lt;SPAN style="color: #011993;"&gt;=&lt;/SPAN&gt;&lt;SPAN style="color: #000000;"&gt; &lt;/SPAN&gt;&lt;SPAN style="color: #032ce4;"&gt;Try&lt;/SPAN&gt;&lt;SPAN style="color: #000000;"&gt;&lt;STRONG&gt;(&lt;/STRONG&gt; x &lt;/SPAN&gt;&lt;SPAN style="color: #011993;"&gt;*&lt;/SPAN&gt;&lt;SPAN style="color: #000000;"&gt; x&lt;/SPAN&gt;&lt;SPAN style="color: #011993;"&gt;,&lt;/SPAN&gt;&lt;SPAN style="color: #000000;"&gt; &lt;/SPAN&gt;"Error, move on!"&lt;SPAN style="color: #000000;"&gt; &lt;STRONG&gt;)&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;SPAN style="color: #011993;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 12px; font-family: Courier; color: #942193;"&gt;&lt;SPAN style="color: #000000;"&gt;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="color: #032ce4;"&gt;Show&lt;/SPAN&gt;&lt;SPAN style="color: #000000;"&gt;&lt;STRONG&gt;(&lt;/STRONG&gt; &lt;/SPAN&gt;"Show this even if x is NaN"&lt;SPAN style="color: #000000;"&gt; &lt;STRONG&gt;)&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;SPAN style="color: #011993;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 12px; font-family: Courier;"&gt;&amp;nbsp; x2&lt;SPAN style="color: #011993;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 12px; font-family: Courier;"&gt;&lt;STRONG&gt;)&lt;/STRONG&gt;&lt;SPAN style="color: #011993;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 12px; font-family: Courier;"&gt;sq &lt;SPAN style="color: #011993;"&gt;=&lt;/SPAN&gt; exsqr&lt;STRONG&gt;(&lt;/STRONG&gt; &lt;SPAN style="color: #942193;"&gt;"q"&lt;/SPAN&gt; &lt;STRONG&gt;)&lt;/STRONG&gt;&lt;SPAN style="color: #011993;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 12px; font-family: Courier; color: #942193;"&gt;&lt;SPAN style="color: #032ce4;"&gt;Show&lt;/SPAN&gt;&lt;SPAN style="color: #000000;"&gt;&lt;STRONG&gt;(&lt;/STRONG&gt; sq&lt;/SPAN&gt;&lt;SPAN style="color: #011993;"&gt;,&lt;/SPAN&gt;&lt;SPAN style="color: #000000;"&gt; &lt;/SPAN&gt;"function escape failed, but script continued"&lt;SPAN style="color: #000000;"&gt; &lt;STRONG&gt;)&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;SPAN style="color: #011993;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 12px; font-family: Courier;"&gt;&lt;/P&gt;&lt;P style="font-size: 12px; font-family: Courier; color: #008f00;"&gt;//Try() enclosing the function call escapes function, script execution continues.&lt;/P&gt;&lt;P style="font-size: 12px; font-family: Courier;"&gt;exsqr &lt;SPAN style="color: #011993;"&gt;=&lt;/SPAN&gt; &lt;SPAN style="color: #032ce4;"&gt;Function&lt;/SPAN&gt;&lt;STRONG&gt;(&lt;/STRONG&gt; &lt;STRONG&gt;{&lt;/STRONG&gt;x&lt;STRONG&gt;}&lt;/STRONG&gt;&lt;SPAN style="color: #011993;"&gt;,&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 12px; font-family: Courier;"&gt;&amp;nbsp; x2 &lt;SPAN style="color: #011993;"&gt;=&lt;/SPAN&gt; x &lt;SPAN style="color: #011993;"&gt;*&lt;/SPAN&gt; x&lt;SPAN style="color: #011993;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 12px; font-family: Courier; color: #942193;"&gt;&lt;SPAN style="color: #000000;"&gt;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="color: #032ce4;"&gt;Show&lt;/SPAN&gt;&lt;SPAN style="color: #000000;"&gt;&lt;STRONG&gt;(&lt;/STRONG&gt; &lt;/SPAN&gt;"Don't show this if x is NaN"&lt;SPAN style="color: #000000;"&gt; &lt;STRONG&gt;)&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;SPAN style="color: #011993;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 12px; font-family: Courier;"&gt;&amp;nbsp; x2&lt;SPAN style="color: #011993;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 12px; font-family: Courier;"&gt;&lt;STRONG&gt;)&lt;/STRONG&gt;&lt;SPAN style="color: #011993;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 12px; font-family: Courier;"&gt;sq &lt;SPAN style="color: #011993;"&gt;=&lt;/SPAN&gt; &lt;SPAN style="color: #032ce4;"&gt;Try&lt;/SPAN&gt;&lt;STRONG&gt;(&lt;/STRONG&gt; exsqr&lt;STRONG&gt;(&lt;/STRONG&gt; &lt;SPAN style="color: #942193;"&gt;"q"&lt;/SPAN&gt; &lt;STRONG&gt;)&lt;/STRONG&gt; &lt;STRONG&gt;)&lt;/STRONG&gt;&lt;SPAN style="color: #011993;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 12px; font-family: Courier; color: #942193;"&gt;&lt;SPAN style="color: #032ce4;"&gt;Show&lt;/SPAN&gt;&lt;SPAN style="color: #000000;"&gt;&lt;STRONG&gt;(&lt;/STRONG&gt; sq&lt;/SPAN&gt;&lt;SPAN style="color: #011993;"&gt;,&lt;/SPAN&gt;&lt;SPAN style="color: #000000;"&gt; &lt;/SPAN&gt;"function escape succeeded!"&lt;SPAN style="color: #000000;"&gt; &lt;STRONG&gt;)&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;SPAN style="color: #011993;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 12px; font-family: Courier;"&gt;&lt;/P&gt;&lt;P style="font-size: 12px; font-family: Courier;"&gt;&lt;/P&gt;&lt;P style="font-size: 12px; font-family: Courier; color: #008f00;"&gt;//Try() with Throw() escapes function and script.&lt;/P&gt;&lt;P style="font-size: 12px; font-family: Courier;"&gt;exsqr &lt;SPAN style="color: #011993;"&gt;=&lt;/SPAN&gt; &lt;SPAN style="color: #032ce4;"&gt;Function&lt;/SPAN&gt;&lt;STRONG&gt;(&lt;/STRONG&gt; &lt;STRONG&gt;{&lt;/STRONG&gt;x&lt;STRONG&gt;}&lt;/STRONG&gt;&lt;SPAN style="color: #011993;"&gt;,&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 12px; font-family: Courier;"&gt;&amp;nbsp; x2 &lt;SPAN style="color: #011993;"&gt;=&lt;/SPAN&gt; &lt;SPAN style="color: #032ce4;"&gt;Try&lt;/SPAN&gt;&lt;STRONG&gt;(&lt;/STRONG&gt; x &lt;SPAN style="color: #011993;"&gt;*&lt;/SPAN&gt; x&lt;SPAN style="color: #011993;"&gt;,&lt;/SPAN&gt; &lt;SPAN style="color: #032ce4;"&gt;Throw&lt;/SPAN&gt;&lt;STRONG&gt;(&lt;/STRONG&gt; &lt;SPAN style="color: #942193;"&gt;"Error, stop here!: "&lt;/SPAN&gt; &lt;SPAN style="color: #011993;"&gt;||&lt;/SPAN&gt; &lt;SPAN style="color: #032ce4;"&gt;Char&lt;/SPAN&gt;&lt;STRONG&gt;(&lt;/STRONG&gt; exception_msg &lt;STRONG&gt;)&lt;/STRONG&gt; &lt;STRONG&gt;)&lt;/STRONG&gt; &lt;STRONG&gt;)&lt;/STRONG&gt;&lt;SPAN style="color: #011993;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 12px; font-family: Courier; color: #942193;"&gt;&lt;SPAN style="color: #000000;"&gt;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="color: #032ce4;"&gt;Show&lt;/SPAN&gt;&lt;SPAN style="color: #000000;"&gt;&lt;STRONG&gt;(&lt;/STRONG&gt; &lt;/SPAN&gt;"Don't show this if x is NaN"&lt;SPAN style="color: #000000;"&gt; &lt;STRONG&gt;)&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;SPAN style="color: #011993;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 12px; font-family: Courier;"&gt;&lt;STRONG&gt;)&lt;/STRONG&gt;&lt;SPAN style="color: #011993;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 12px; font-family: Courier;"&gt;sq &lt;SPAN style="color: #011993;"&gt;=&lt;/SPAN&gt; exsqr&lt;STRONG&gt;(&lt;/STRONG&gt; &lt;SPAN style="color: #942193;"&gt;"q"&lt;/SPAN&gt; &lt;STRONG&gt;)&lt;/STRONG&gt;&lt;SPAN style="color: #011993;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 12px; font-family: Courier; color: #942193;"&gt;&lt;SPAN style="color: #032ce4;"&gt;Show&lt;/SPAN&gt;&lt;SPAN style="color: #000000;"&gt;&lt;STRONG&gt;(&lt;/STRONG&gt; sq&lt;/SPAN&gt;&lt;SPAN style="color: #011993;"&gt;,&lt;/SPAN&gt;&lt;SPAN style="color: #000000;"&gt; &lt;/SPAN&gt;"script stopped!"&lt;SPAN style="color: #000000;"&gt; &lt;STRONG&gt;)&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;SPAN style="color: #011993;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 02 Jan 2013 21:19:23 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Jump-out-of-a-function/m-p/6133#M6132</guid>
      <dc:creator>ms</dc:creator>
      <dc:date>2013-01-02T21:19:23Z</dc:date>
    </item>
    <item>
      <title>Re: Jump out of a function?</title>
      <link>https://community.jmp.com/t5/Discussions/Jump-out-of-a-function/m-p/281988#M54572</link>
      <description>&lt;P&gt;Could you use &lt;STRONG&gt;return()&lt;/STRONG&gt;?&lt;/P&gt;</description>
      <pubDate>Sat, 25 Jul 2020 21:29:30 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Jump-out-of-a-function/m-p/281988#M54572</guid>
      <dc:creator>andrewtkarl</dc:creator>
      <dc:date>2020-07-25T21:29:30Z</dc:date>
    </item>
    <item>
      <title>Re: Jump out of a function?</title>
      <link>https://community.jmp.com/t5/Discussions/Jump-out-of-a-function/m-p/281998#M54575</link>
      <description>Yes,   return()    will break out of a function</description>
      <pubDate>Sat, 25 Jul 2020 23:28:26 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Jump-out-of-a-function/m-p/281998#M54575</guid>
      <dc:creator>txnelson</dc:creator>
      <dc:date>2020-07-25T23:28:26Z</dc:date>
    </item>
    <item>
      <title>Re: Jump out of a function?</title>
      <link>https://community.jmp.com/t5/Discussions/Jump-out-of-a-function/m-p/800603#M97620</link>
      <description>&lt;P&gt;I am getting an error when trying to exit a function with return().&lt;/P&gt;&lt;P&gt;I get the error when I make a button box&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;bb = Button Box("SpecsAuto")&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;then attach a function&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;bb &amp;lt;&amp;lt;&amp;nbsp;Set Function( Return() )&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;then click the box.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here is demo code to reproduce the error:&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;nw = New Window("Win1");
nw &amp;lt;&amp;lt; Append(bb = Button Box("SpecsAuto"));
bb &amp;lt;&amp;lt; Set Function(
	Print("A");
	Return();
	Print("B");
);
bb &amp;lt;&amp;lt; Click();&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="bswedlove_0-1726781008643.png" style="width: 400px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/68479i560037006F77C250/image-size/medium?v=v2&amp;amp;px=400" role="button" title="bswedlove_0-1726781008643.png" alt="bswedlove_0-1726781008643.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 19 Sep 2024 21:34:43 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Jump-out-of-a-function/m-p/800603#M97620</guid>
      <dc:creator>bswedlove</dc:creator>
      <dc:date>2024-09-19T21:34:43Z</dc:date>
    </item>
    <item>
      <title>Re: Jump out of a function?</title>
      <link>https://community.jmp.com/t5/Discussions/Jump-out-of-a-function/m-p/800718#M97621</link>
      <description>&lt;P&gt;&lt;FONT face="courier new,courier"&gt;set function()&lt;/FONT&gt; also works if no function is provided - like in your script.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;To use the magic of &lt;FONT face="courier new,courier"&gt;return()&lt;/FONT&gt;, you have to put it inside a function:&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;nw = New Window("Win1");
nw &amp;lt;&amp;lt; Append(bb = Button Box("SpecsAuto"));
bb &amp;lt;&amp;lt; Set function(Function({},
	Print("A");
	Return();
	Print("B");)
);
bb &amp;lt;&amp;lt; Click();&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 20 Sep 2024 05:48:45 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Jump-out-of-a-function/m-p/800718#M97621</guid>
      <dc:creator>hogi</dc:creator>
      <dc:date>2024-09-20T05:48:45Z</dc:date>
    </item>
  </channel>
</rss>

