<?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: Loop on script files in Discussions</title>
    <link>https://community.jmp.com/t5/Discussions/Loop-on-script-files/m-p/443314#M69148</link>
    <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.jmp.com/t5/user/viewprofilepage/user-id/16668"&gt;@J_Bonnouvrier1&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp; In that case, all you need to do is make sure that your directory path is correctly defined (with the last backslash included), and that you need to concatenate the ".jsl" ending to make sure things work as expected.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;As an example, I created three Product JSL files, each with the following commands, but just changing the numbers from 1, to 2, and then 3:&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Names Default to Here (1);

Print("This is Product 1 JSL script");&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;The main JSL file is as follows:&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Names Default to Here (1);

Product_List={"Product1", "Product2", "Product3"};
ScriptDir = "C:\temp\"; //Or whatever your path is.

Print("This is the main script");

For(i=1, i&amp;lt;=NItems(Product_List), i++,
	Include(ScriptDir||Product_List[i]||".jsl");
);&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;The output of running the above main code is:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;"This is the main script"&lt;BR /&gt;"This is Product 1 JSL script"&lt;BR /&gt;"This is Product 2 JSL script"&lt;BR /&gt;"This is Product 3 JSL script"&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp; It will also work out if you have the ".jsl" as part of the product list, like: Product_List={"Product1.jsl", "Product2.jsl",...}; and then you would remove the ||".jsl" concatenation from the For loop. Either way, you get the same output as above. It just depends on how you want to define the Product_List list.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Hope this helps!,&lt;/P&gt;&lt;P&gt;DS&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Wed, 08 Dec 2021 13:33:21 GMT</pubDate>
    <dc:creator>SDF1</dc:creator>
    <dc:date>2021-12-08T13:33:21Z</dc:date>
    <item>
      <title>Loop on script files</title>
      <link>https://community.jmp.com/t5/Discussions/Loop-on-script-files/m-p/443100#M69123</link>
      <description>&lt;P&gt;Dear jsl scripters,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I have a script in which I use the include instruction to call a subscript for "reporting" (inserting a JMP chart into a powerpoint file):&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;dt = Current Data Table();
Include( strRootPathScript || str_report_Product1) );&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;It works fine as long as I use 1 product. My wish is to loop on a liste of products [Product1;Product2;...]&lt;/P&gt;
&lt;P&gt;and to replace the product name into the include instruction.&lt;/P&gt;
&lt;P&gt;After some exotic trials around the EVAL/EXPR/SUBSTITUTE instructions, I am begging your help!&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks!!!&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Jerome&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 09 Jun 2023 18:06:52 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Loop-on-script-files/m-p/443100#M69123</guid>
      <dc:creator>J_Bonnouvrier1</dc:creator>
      <dc:date>2023-06-09T18:06:52Z</dc:date>
    </item>
    <item>
      <title>Re: Loop on script files</title>
      <link>https://community.jmp.com/t5/Discussions/Loop-on-script-files/m-p/443119#M69124</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.jmp.com/t5/user/viewprofilepage/user-id/16668"&gt;@J_Bonnouvrier1&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp; It's a little hard to generalize this to work under any circumstance, but you could loop through it given a code/file structure as I imagine it.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp; Assuming that you know before hand the substitutions Product1, Product2, etc In your JSL code, if you do something like:&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;dt = Current Data Table();

For(i=1, i&amp;lt;=NItems(Product_List), i++,
  Include(strRootPathScript||"str_report_"||Product_List[i]);
);&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;In this case, the variable Product_List would be a list of your products: Product_List={"Product1", "Product2", "Product3",...};. In the For loop, when it calls Product_List[i], it would be concatenating the ith element of Product_List. So, if i = 3, it should do the following:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Include(strRootPathScript||str_report_||Product_List[3]) , where I'm assuming strRootPathScript is some root path, like "C:\myfiles\JSL_code\", so that the argument you're feeding into the Include function would in this case be: "C:\myfiles\JSL_code\str_report_Product3".&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp; Is this kind of what you're after?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Hope this helps!,&lt;/P&gt;&lt;P&gt;DS&lt;/P&gt;</description>
      <pubDate>Tue, 07 Dec 2021 17:57:29 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Loop-on-script-files/m-p/443119#M69124</guid>
      <dc:creator>SDF1</dc:creator>
      <dc:date>2021-12-07T17:57:29Z</dc:date>
    </item>
    <item>
      <title>Re: Loop on script files</title>
      <link>https://community.jmp.com/t5/Discussions/Loop-on-script-files/m-p/443225#M69139</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.jmp.com/t5/user/viewprofilepage/user-id/12549"&gt;@SDF1&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Actually I forgot to mention that&amp;nbsp;str_report_Product1 is a variable giving the name of the file for each product:&lt;/P&gt;&lt;P&gt;str_report_Product1 = "C:\temp\report_Product1.jsl"&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;So, the solution you propose is not recognized by the script.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks and regards,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Jérôme&lt;/P&gt;</description>
      <pubDate>Wed, 08 Dec 2021 08:09:57 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Loop-on-script-files/m-p/443225#M69139</guid>
      <dc:creator>J_Bonnouvrier1</dc:creator>
      <dc:date>2021-12-08T08:09:57Z</dc:date>
    </item>
    <item>
      <title>Re: Loop on script files</title>
      <link>https://community.jmp.com/t5/Discussions/Loop-on-script-files/m-p/443314#M69148</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.jmp.com/t5/user/viewprofilepage/user-id/16668"&gt;@J_Bonnouvrier1&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp; In that case, all you need to do is make sure that your directory path is correctly defined (with the last backslash included), and that you need to concatenate the ".jsl" ending to make sure things work as expected.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;As an example, I created three Product JSL files, each with the following commands, but just changing the numbers from 1, to 2, and then 3:&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Names Default to Here (1);

Print("This is Product 1 JSL script");&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;The main JSL file is as follows:&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Names Default to Here (1);

Product_List={"Product1", "Product2", "Product3"};
ScriptDir = "C:\temp\"; //Or whatever your path is.

Print("This is the main script");

For(i=1, i&amp;lt;=NItems(Product_List), i++,
	Include(ScriptDir||Product_List[i]||".jsl");
);&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;The output of running the above main code is:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;"This is the main script"&lt;BR /&gt;"This is Product 1 JSL script"&lt;BR /&gt;"This is Product 2 JSL script"&lt;BR /&gt;"This is Product 3 JSL script"&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp; It will also work out if you have the ".jsl" as part of the product list, like: Product_List={"Product1.jsl", "Product2.jsl",...}; and then you would remove the ||".jsl" concatenation from the For loop. Either way, you get the same output as above. It just depends on how you want to define the Product_List list.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Hope this helps!,&lt;/P&gt;&lt;P&gt;DS&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 08 Dec 2021 13:33:21 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Loop-on-script-files/m-p/443314#M69148</guid>
      <dc:creator>SDF1</dc:creator>
      <dc:date>2021-12-08T13:33:21Z</dc:date>
    </item>
  </channel>
</rss>

