<?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 How to run a part of script or include a script based on a condition in Discussions</title>
    <link>https://community.jmp.com/t5/Discussions/How-to-run-a-part-of-script-or-include-a-script-based-on-a/m-p/499961#M73510</link>
    <description>&lt;P&gt;Hi All,&lt;BR /&gt;&lt;BR /&gt;I am trying to run a part of a script based on condition on a column. If that condition is failed, it should run other part of the script or include other script.&lt;BR /&gt;&lt;BR /&gt;It seems very simple but I am not able to do that. I have followed two approaches - using&amp;nbsp; "include" function to call a script&amp;nbsp; and "Expr" function to call a part of the code. None is working. Any help here ?&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;1st Approach -&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;dt = Data Table( "Data" ) &amp;lt;&amp;lt; If ( PRODUCT == "A", include("C:\....\Script1.jsl"), include("C:\....\Script2.jsl"), );&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;This is not working while both scripts 1 and 2 are working independently.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;2nd Approach is similar to 1st but using "Expr", the way mentioned in -&amp;nbsp;&lt;LI-MESSAGE title="Sectioning or Segmenting Code in JSL" uid="40824" url="https://community.jmp.com/t5/Discussions/Sectioning-or-Segmenting-Code-in-JSL/m-p/40824#U40824" 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;&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;Many thanks,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Fri, 09 Jun 2023 17:00:37 GMT</pubDate>
    <dc:creator>HSS</dc:creator>
    <dc:date>2023-06-09T17:00:37Z</dc:date>
    <item>
      <title>How to run a part of script or include a script based on a condition</title>
      <link>https://community.jmp.com/t5/Discussions/How-to-run-a-part-of-script-or-include-a-script-based-on-a/m-p/499961#M73510</link>
      <description>&lt;P&gt;Hi All,&lt;BR /&gt;&lt;BR /&gt;I am trying to run a part of a script based on condition on a column. If that condition is failed, it should run other part of the script or include other script.&lt;BR /&gt;&lt;BR /&gt;It seems very simple but I am not able to do that. I have followed two approaches - using&amp;nbsp; "include" function to call a script&amp;nbsp; and "Expr" function to call a part of the code. None is working. Any help here ?&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;1st Approach -&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;dt = Data Table( "Data" ) &amp;lt;&amp;lt; If ( PRODUCT == "A", include("C:\....\Script1.jsl"), include("C:\....\Script2.jsl"), );&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;This is not working while both scripts 1 and 2 are working independently.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;2nd Approach is similar to 1st but using "Expr", the way mentioned in -&amp;nbsp;&lt;LI-MESSAGE title="Sectioning or Segmenting Code in JSL" uid="40824" url="https://community.jmp.com/t5/Discussions/Sectioning-or-Segmenting-Code-in-JSL/m-p/40824#U40824" 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;&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;Many thanks,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 09 Jun 2023 17:00:37 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/How-to-run-a-part-of-script-or-include-a-script-based-on-a/m-p/499961#M73510</guid>
      <dc:creator>HSS</dc:creator>
      <dc:date>2023-06-09T17:00:37Z</dc:date>
    </item>
    <item>
      <title>Re: How to run a part of script or include a script based on a condition</title>
      <link>https://community.jmp.com/t5/Discussions/How-to-run-a-part-of-script-or-include-a-script-based-on-a/m-p/500056#M73515</link>
      <description>&lt;P&gt;I believe the issue you are having is in attempting to pass the If() statement to the data table.&amp;nbsp; What should work is&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;dt = Data Table( "Data" );
If ( PRODUCT == "A", include("C:\....\Script1.jsl"), include("C:\....\Script2.jsl"), );&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sun, 05 Jun 2022 15:24:33 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/How-to-run-a-part-of-script-or-include-a-script-based-on-a/m-p/500056#M73515</guid>
      <dc:creator>txnelson</dc:creator>
      <dc:date>2022-06-05T15:24:33Z</dc:date>
    </item>
    <item>
      <title>Re: How to run a part of script or include a script based on a condition</title>
      <link>https://community.jmp.com/t5/Discussions/How-to-run-a-part-of-script-or-include-a-script-based-on-a/m-p/500063#M73516</link>
      <description>&lt;P&gt;Hi Nelson,&lt;BR /&gt;&lt;BR /&gt;I have tried that as well. That is also not working.&lt;/P&gt;</description>
      <pubDate>Sun, 05 Jun 2022 15:33:51 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/How-to-run-a-part-of-script-or-include-a-script-based-on-a/m-p/500063#M73516</guid>
      <dc:creator>HSS</dc:creator>
      <dc:date>2022-06-05T15:33:51Z</dc:date>
    </item>
    <item>
      <title>Re: How to run a part of script or include a script based on a condition</title>
      <link>https://community.jmp.com/t5/Discussions/How-to-run-a-part-of-script-or-include-a-script-based-on-a/m-p/500076#M73517</link>
      <description>&lt;P&gt;I think we might need a bit more information about what you are trying to do and what the "external" parts are. Include() and expressions should both work just fine if you are just running parts of some code.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Names Default To Here(1);

exprA = Expr(Show("A"));
exprB = Expr(Show("B"));

PRODUCT = "B";

If(PRODUCT == "A",
	exprA;
,
	exprB;
);&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sun, 05 Jun 2022 15:42:24 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/How-to-run-a-part-of-script-or-include-a-script-based-on-a/m-p/500076#M73517</guid>
      <dc:creator>jthi</dc:creator>
      <dc:date>2022-06-05T15:42:24Z</dc:date>
    </item>
    <item>
      <title>Re: How to run a part of script or include a script based on a condition</title>
      <link>https://community.jmp.com/t5/Discussions/How-to-run-a-part-of-script-or-include-a-script-based-on-a/m-p/500089#M73518</link>
      <description>&lt;P&gt;I ran this code without error&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Names Default To Here( 1 );

b = 1;

If( b == 1,
	Include( "path to one of the includes" ),
	Include( "path to the second include" )
);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;The first include code was&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;a=1;
show(a);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;The second include code was:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;a=2;
show(a);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;and it worked as expected&lt;/P&gt;
&lt;P&gt;As&amp;nbsp;&lt;a href="https://community.jmp.com/t5/user/viewprofilepage/user-id/14366"&gt;@jthi&lt;/a&gt;&amp;nbsp;has suggested you probably need to provide more information about the includes.&lt;/P&gt;</description>
      <pubDate>Sun, 05 Jun 2022 16:56:50 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/How-to-run-a-part-of-script-or-include-a-script-based-on-a/m-p/500089#M73518</guid>
      <dc:creator>txnelson</dc:creator>
      <dc:date>2022-06-05T16:56:50Z</dc:date>
    </item>
    <item>
      <title>Re: How to run a part of script or include a script based on a condition</title>
      <link>https://community.jmp.com/t5/Discussions/How-to-run-a-part-of-script-or-include-a-script-based-on-a/m-p/500713#M73528</link>
      <description>&lt;P&gt;Hello &lt;a href="https://community.jmp.com/t5/user/viewprofilepage/user-id/2687"&gt;@txnelson&lt;/a&gt;&amp;nbsp; and &lt;a href="https://community.jmp.com/t5/user/viewprofilepage/user-id/14366"&gt;@jthi&lt;/a&gt;,&lt;BR /&gt;&lt;BR /&gt;Actually both of yours codes are working fine (and in fact, my own way is also working). The issue was with JMP session.&amp;nbsp; After few more attempts my JMP crashed and I gave up. Today after restarting the JMP, the same code is working fine. I believe it may be same memory/cache/path/variables issue with JMP session. Once it is restarted, it worked fine.&lt;BR /&gt;&lt;BR /&gt;I am really thankful for both of yours support.&lt;BR /&gt;&lt;BR /&gt;Reards, HSS&lt;/P&gt;</description>
      <pubDate>Mon, 06 Jun 2022 17:13:59 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/How-to-run-a-part-of-script-or-include-a-script-based-on-a/m-p/500713#M73528</guid>
      <dc:creator>HSS</dc:creator>
      <dc:date>2022-06-06T17:13:59Z</dc:date>
    </item>
    <item>
      <title>Re: How to run a part of script or include a script based on a condition</title>
      <link>https://community.jmp.com/t5/Discussions/How-to-run-a-part-of-script-or-include-a-script-based-on-a/m-p/500736#M73529</link>
      <description>&lt;P&gt;Happens from time to time. If you aren't already, I suggest starting all your scripts with&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Names Default To Here(1);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;It will provide you some protection against namespace collisions. This link is fairly helpful regarding Names Default To Here(1) (there is multiple pages)&amp;nbsp;&lt;A href="https://www.jmp.com/support/help/en/16.2/#page/jmp/advanced-scoping-and-namespaces.shtml" target="_blank" rel="noopener"&gt; Scripting Guide &amp;gt; Programming Methods &amp;gt; Advanced Scoping and Namespaces (jmp.com)&lt;/A&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 06 Jun 2022 17:52:07 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/How-to-run-a-part-of-script-or-include-a-script-based-on-a/m-p/500736#M73529</guid>
      <dc:creator>jthi</dc:creator>
      <dc:date>2022-06-06T17:52:07Z</dc:date>
    </item>
    <item>
      <title>Re: How to run a part of script or include a script based on a condition</title>
      <link>https://community.jmp.com/t5/Discussions/How-to-run-a-part-of-script-or-include-a-script-based-on-a/m-p/501058#M73536</link>
      <description>&lt;P&gt;Thanks Jarmo,&lt;BR /&gt;&lt;BR /&gt;I learnt using&amp;nbsp;&lt;/P&gt;&lt;PRE class="language-jsl"&gt;&lt;CODE&gt;Names Default To Here(1);&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;BR /&gt;from Nelson (&lt;a href="https://community.jmp.com/t5/user/viewprofilepage/user-id/2687"&gt;@txnelson&lt;/a&gt;) few years back and I do use it. I will have a look into the guideline again.&lt;BR /&gt;Thank you guys.&lt;/P&gt;</description>
      <pubDate>Tue, 07 Jun 2022 02:50:26 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/How-to-run-a-part-of-script-or-include-a-script-based-on-a/m-p/501058#M73536</guid>
      <dc:creator>HSS</dc:creator>
      <dc:date>2022-06-07T02:50:26Z</dc:date>
    </item>
  </channel>
</rss>

