<?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 JSL script help in Discussions</title>
    <link>https://community.jmp.com/t5/Discussions/JSL-script-help/m-p/448798#M69561</link>
    <description>&lt;P&gt;This is related to the partition script, I am trying to save the selected and unselected rows as different tables after partition function. But when I do that the whole JSL script goes into an infinite loop. Is there any way to solve this?&lt;/P&gt;</description>
    <pubDate>Sat, 10 Jun 2023 23:42:07 GMT</pubDate>
    <dc:creator>shasha_2</dc:creator>
    <dc:date>2023-06-10T23:42:07Z</dc:date>
    <item>
      <title>JSL script help</title>
      <link>https://community.jmp.com/t5/Discussions/JSL-script-help/m-p/448798#M69561</link>
      <description>&lt;P&gt;This is related to the partition script, I am trying to save the selected and unselected rows as different tables after partition function. But when I do that the whole JSL script goes into an infinite loop. Is there any way to solve this?&lt;/P&gt;</description>
      <pubDate>Sat, 10 Jun 2023 23:42:07 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/JSL-script-help/m-p/448798#M69561</guid>
      <dc:creator>shasha_2</dc:creator>
      <dc:date>2023-06-10T23:42:07Z</dc:date>
    </item>
    <item>
      <title>Re: JSL script help</title>
      <link>https://community.jmp.com/t5/Discussions/JSL-script-help/m-p/448819#M69562</link>
      <description>&lt;P&gt;I would guess it goes into infinite loop because you make new selection of rows inside the row state handler (invert row selection). You could try to avoid selection of rows by using the parameter &lt;STRONG&gt;a&lt;/STRONG&gt;&amp;nbsp; you have already in the function (it should tell the rows which had states changed) with some idea of this:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Names Default To Here(1);
dt = Open("$SAMPLE_DATA/big class.jmp");

tableCount = 0;
theRows = [];
filepath = "$Desktop";

f = Function({a}, 
	// Set dupRows to the previously selected rows
	dupRows = theRows;
	// Get the current selected rows
	theRows = a;
	If(N Rows(theRows) &amp;gt; 0, 
		// check to see if there are the same number of rows
		// then validate the rows are different rows before saving
		If(N Rows(theRows) == N Rows(dupRows),
			If(Sum(dupRows == theRows) != N Rows(theRows),
				tableCount++;
				dtTemp = dt &amp;lt;&amp;lt; subset(invisible, rows(theRows), selected columns(0));
				dtSEG = dt &amp;lt;&amp;lt; subset(rows(dupRows), selected columns(0));
				Close(dtTemp, save(filepath || "\" || "part" || ".jmp"));
				Close(dtSEG, save(filepath || "\" || "seg2" || ".jmp"));
			)
		, 
			// If not the same number of selected rows, save the subset
			tableCount++;
			dtTemp = dt &amp;lt;&amp;lt; subset(invisible, rows(theRows), selected columns(0));
			dtSEG = dt &amp;lt;&amp;lt; subset(rows(dupRows), selected columns(0));
			Close(dtTemp, save(filepath || "\" || "part" || Char(tableCount) || ".jmp"));
			Close(dtSEG, save(filepath || "\" || "seg2" || Char(tableCount) || ".jmp"));
		)
	);
	Show(a, tableCount); //debug print
);

rs = Current Data Table() &amp;lt;&amp;lt; make row state handler(f);&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;I would most likely avoid row state handler and use some sort of new window in which user can press a button when selections have been done. This is because I have had a fair bit of issues with Row State Handlers and try to avoid them whenever possible.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 04 Jan 2022 09:12:15 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/JSL-script-help/m-p/448819#M69562</guid>
      <dc:creator>jthi</dc:creator>
      <dc:date>2022-01-04T09:12:15Z</dc:date>
    </item>
    <item>
      <title>Re: JSL script help</title>
      <link>https://community.jmp.com/t5/Discussions/JSL-script-help/m-p/450015#M69687</link>
      <description>&lt;P&gt;Thank you for the help. Now, it is working properly, I have removed the row state handler and used a function which is called on close of the window. This does the creation of two subsets.&lt;/P&gt;</description>
      <pubDate>Mon, 10 Jan 2022 04:18:39 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/JSL-script-help/m-p/450015#M69687</guid>
      <dc:creator>shasha_2</dc:creator>
      <dc:date>2022-01-10T04:18:39Z</dc:date>
    </item>
  </channel>
</rss>

