<?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: Challenges constructing a proper loop in Discussions</title>
    <link>https://community.jmp.com/t5/Discussions/Challenges-constructing-a-proper-loop/m-p/663374#M85196</link>
    <description>&lt;P&gt;Use ctrl-M in the editor to format the jsl:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;dt = Current Data Table();
//declaring and initializing variables//
lt_min = 1;
lt_max = 50;
RSquare_th = 0.9999;
count = 0;
//loop
While( count &amp;lt; 0.99999, 
//calculate x for each y value
	dt &amp;lt;&amp;lt; New Column( "x", Numeric, formula( :y / (:y + :avg_num) ) );
//plot bivariate
	biv = dt &amp;lt;&amp;lt; Bivariate(
		Y( :x ),
		X( :average_temp ),
		Fit Line( {Line Color( {212, 73, 88} )} )
	);
	Bivariate_report = biv &amp;lt;&amp;lt; report;
	pt = Bivariate_report[Table Box( 1 )];
	pt &amp;lt;&amp;lt; Make Combined Data Table();
	pt = Bivariate_report[Table Box( 3 )];
	pt &amp;lt;&amp;lt; Make Combined Data Table();
);
//get rsquare
rsquare &amp;lt;&amp;lt; Send( Bivariate Fit );
rsquare &amp;lt;&amp;lt; Send( Get Gen RSquare Test );
//check Rsq
If(
	rsquare &amp;lt; RSquare_th, 
	//increment light by 1
		lt_min = lt_min + 1,
	count = count + 1, 
	//update data table
		dt &amp;lt;&amp;lt; New Column( "light", Numeric, formula( lt_min ) ), 
	//exit loop if RSQ &amp;gt;= threshold
	Print( "Search Completed. RSQ &amp;gt;= threshold" ),
);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;The indentation will help understand what code the loop is running. In particular, notice the count=count+1 is not inside the loop, so it will not terminate.&lt;/P&gt;
&lt;P&gt;edit: the if statement needs work too, see &lt;LI-MESSAGE title="If Secrets" uid="39558" url="https://community.jmp.com/t5/Uncharted/If-Secrets/m-p/39558#U39558" discussion_style_icon_css="lia-mention-container-editor-message lia-img-icon-blog-thread lia-fa-icon lia-fa-blog lia-fa-thread lia-fa"&gt;&lt;/LI-MESSAGE&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Fri, 28 Jul 2023 14:59:32 GMT</pubDate>
    <dc:creator>Craige_Hales</dc:creator>
    <dc:date>2023-07-28T14:59:32Z</dc:date>
    <item>
      <title>Challenges constructing a proper loop</title>
      <link>https://community.jmp.com/t5/Discussions/Challenges-constructing-a-proper-loop/m-p/663370#M85195</link>
      <description>&lt;P&gt;Hi,&amp;nbsp;&lt;/P&gt;&lt;P&gt;Im new to coding and having challenges constructing a functioning script&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;dt = current data table();
//declaring and initializing variables//
lt_min = 1;
lt_max = 50;
RSquare_th = 0.9999;
count = 0;
//loop
while (count &amp;lt; 0.99999, 
//calculate x for each y value
dt &amp;lt;&amp;lt; New Column ("x", Numeric, formula(:y/ (:y + :avg_num)));
//plot bivariate
biv = dt &amp;lt;&amp;lt; Bivariate( 
	Y( :x ),
	 X( :average_temp),
	 Fit Line( {Line Color( {212, 73, 88} )} ));
Bivariate_report = biv &amp;lt;&amp;lt; report;
pt = Bivariate_report [Table Box(1)];
pt &amp;lt;&amp;lt; Make Combined Data Table();
pt = Bivariate_report [Table Box(3)];
pt &amp;lt;&amp;lt; Make Combined Data Table();
);
//get rsquare
rsquare &amp;lt;&amp;lt; send (Bivariate Fit);
rsquare  &amp;lt;&amp;lt; send(Get Gen RSquare Test);
//check Rsq
if (rsquare &amp;lt; RSquare_th,
	//increment light by 1
	lt_min = lt_min +1,
	count = count +1,
	//update data table
	dt &amp;lt;&amp;lt; New Column("light", Numeric, formula(lt_min)),
	//exit loop if RSQ &amp;gt;= threshold
	print("Search Completed. RSQ &amp;gt;= threshold"),
);&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;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 28 Jul 2023 14:32:51 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Challenges-constructing-a-proper-loop/m-p/663370#M85195</guid>
      <dc:creator>ParametricStudy</dc:creator>
      <dc:date>2023-07-28T14:32:51Z</dc:date>
    </item>
    <item>
      <title>Re: Challenges constructing a proper loop</title>
      <link>https://community.jmp.com/t5/Discussions/Challenges-constructing-a-proper-loop/m-p/663374#M85196</link>
      <description>&lt;P&gt;Use ctrl-M in the editor to format the jsl:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;dt = Current Data Table();
//declaring and initializing variables//
lt_min = 1;
lt_max = 50;
RSquare_th = 0.9999;
count = 0;
//loop
While( count &amp;lt; 0.99999, 
//calculate x for each y value
	dt &amp;lt;&amp;lt; New Column( "x", Numeric, formula( :y / (:y + :avg_num) ) );
//plot bivariate
	biv = dt &amp;lt;&amp;lt; Bivariate(
		Y( :x ),
		X( :average_temp ),
		Fit Line( {Line Color( {212, 73, 88} )} )
	);
	Bivariate_report = biv &amp;lt;&amp;lt; report;
	pt = Bivariate_report[Table Box( 1 )];
	pt &amp;lt;&amp;lt; Make Combined Data Table();
	pt = Bivariate_report[Table Box( 3 )];
	pt &amp;lt;&amp;lt; Make Combined Data Table();
);
//get rsquare
rsquare &amp;lt;&amp;lt; Send( Bivariate Fit );
rsquare &amp;lt;&amp;lt; Send( Get Gen RSquare Test );
//check Rsq
If(
	rsquare &amp;lt; RSquare_th, 
	//increment light by 1
		lt_min = lt_min + 1,
	count = count + 1, 
	//update data table
		dt &amp;lt;&amp;lt; New Column( "light", Numeric, formula( lt_min ) ), 
	//exit loop if RSQ &amp;gt;= threshold
	Print( "Search Completed. RSQ &amp;gt;= threshold" ),
);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;The indentation will help understand what code the loop is running. In particular, notice the count=count+1 is not inside the loop, so it will not terminate.&lt;/P&gt;
&lt;P&gt;edit: the if statement needs work too, see &lt;LI-MESSAGE title="If Secrets" uid="39558" url="https://community.jmp.com/t5/Uncharted/If-Secrets/m-p/39558#U39558" discussion_style_icon_css="lia-mention-container-editor-message lia-img-icon-blog-thread lia-fa-icon lia-fa-blog lia-fa-thread lia-fa"&gt;&lt;/LI-MESSAGE&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 28 Jul 2023 14:59:32 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Challenges-constructing-a-proper-loop/m-p/663374#M85196</guid>
      <dc:creator>Craige_Hales</dc:creator>
      <dc:date>2023-07-28T14:59:32Z</dc:date>
    </item>
  </channel>
</rss>

