<?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: For Loop in &amp;quot;Expr&amp;quot; not working in Discussions</title>
    <link>https://community.jmp.com/t5/Discussions/For-Loop-in-quot-Expr-quot-not-working/m-p/954899#M110049</link>
    <description>&lt;P&gt;I would create function for this and within that function, I would move the For loop outside of the platform run.&lt;/P&gt;
&lt;P&gt;I think something like this could work (there are plenty of other options)&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Names Default To Here(1);

create_oneway = Function({dt, colpara, splitpara, n = 100}, {Default Local},
	ow = dt &amp;lt;&amp;lt; OneWay(
		Y(Eval(colPara)), 
		X(Eval(splitPara)),
		MeansAndStdDev(0), 
		AllGraphs(0), 
		LineOfFit(0), 
		StdDevLines(1), 
		Legend(1), 
		PlotQuantileByActual(1)
	);
	
	rep = ow &amp;lt;&amp;lt; report;
	For(l = 0, l &amp;lt;= n, l++,
		rep &amp;lt;&amp;lt; Dispatch(
			{"Normal Quantile Plot"}, "2", ScaleBox, 
			{
				Format("Best", 6),
				Add Ref Line(l/100, "Dotted", "Black", Char(l) || "/100", 1)
			}
		);
	);
	
	rep &amp;lt;&amp;lt; Dispatch({}, "Normal Quantile Plot", OutlineBox, {SetTitle("")});
	
	return(ow);
);


dt = open("$SAMPLE_DATA/Big Class.jmp");


ow = create_oneway(dt, "weight", "age");

Write();
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You could use Expr but in that case I would build the expression from few different parts&lt;/P&gt;</description>
    <pubDate>Mon, 22 Jun 2026 17:46:54 GMT</pubDate>
    <dc:creator>jthi</dc:creator>
    <dc:date>2026-06-22T17:46:54Z</dc:date>
    <item>
      <title>For Loop in "Expr" not working</title>
      <link>https://community.jmp.com/t5/Discussions/For-Loop-in-quot-Expr-quot-not-working/m-p/954837#M110047</link>
      <description>&lt;P&gt;Hello,&lt;BR /&gt;this is a representation of the script I am having a problem with:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;n = 100;

ow = Expr(
	OneWay(Y(colPara), X(splitPara),
		MeansAndStdDev(0), AllGraphs(0), LineOfFit(0), StdDevLines(1), Legend(1), PlotQuantileByActual(1),
		SendToReport(
			Dispatch({}, "Normal Quantile Plot", OutlineBox, {SetTitle("")}),&lt;BR /&gt;&lt;CODE class="language-jsl"&gt;			&lt;/CODE&gt;For(l = 0, l &amp;lt;= n, l++, Dispatch({"Normal Quantile Plot"}, "2", ScaleBox, {Format("Best", 6), AddRefLine(l/100, "Dotted", "Black", Char(l) || "/100", 1), ) ) ) ); rep = Eval(EvalExpr(ow)) &amp;lt;&amp;lt; Report;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;So I am trying to create save a OneWay-Plot in an expression that will be evaluated later and turned into a report.&lt;BR /&gt;The first dispatch does what it is intended to do:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Dispatch({}, "Normal Quantile Plot", OutlineBox, {SetTitle("")})&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;However, the For Loop doesn't work and I believe it has something to do with how JMP handles running variables in combination with the Expr/Eval works.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class="language-jsl"&gt;For(l = 0, l &amp;lt;= n, l++, &lt;BR /&gt;	Dispatch({"Normal Quantile Plot"}, "2", ScaleBox, {Format("Best", 6), AddRefLine(l/100, "Dotted", "Black", Char(l) || "/100", 1),&lt;BR /&gt;)&lt;/CODE&gt;&lt;CODE class=" language-jsl"&gt;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;CODE class="language-jsl"&gt;&lt;/CODE&gt;&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;Is there some sort of solution or workaround for this?&lt;BR /&gt;Best regards &amp;lt;3&lt;/img&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 22 Jun 2026 12:00:09 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/For-Loop-in-quot-Expr-quot-not-working/m-p/954837#M110047</guid>
      <dc:creator>nozellot</dc:creator>
      <dc:date>2026-06-22T12:00:09Z</dc:date>
    </item>
    <item>
      <title>Re: For Loop in "Expr" not working</title>
      <link>https://community.jmp.com/t5/Discussions/For-Loop-in-quot-Expr-quot-not-working/m-p/954899#M110049</link>
      <description>&lt;P&gt;I would create function for this and within that function, I would move the For loop outside of the platform run.&lt;/P&gt;
&lt;P&gt;I think something like this could work (there are plenty of other options)&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Names Default To Here(1);

create_oneway = Function({dt, colpara, splitpara, n = 100}, {Default Local},
	ow = dt &amp;lt;&amp;lt; OneWay(
		Y(Eval(colPara)), 
		X(Eval(splitPara)),
		MeansAndStdDev(0), 
		AllGraphs(0), 
		LineOfFit(0), 
		StdDevLines(1), 
		Legend(1), 
		PlotQuantileByActual(1)
	);
	
	rep = ow &amp;lt;&amp;lt; report;
	For(l = 0, l &amp;lt;= n, l++,
		rep &amp;lt;&amp;lt; Dispatch(
			{"Normal Quantile Plot"}, "2", ScaleBox, 
			{
				Format("Best", 6),
				Add Ref Line(l/100, "Dotted", "Black", Char(l) || "/100", 1)
			}
		);
	);
	
	rep &amp;lt;&amp;lt; Dispatch({}, "Normal Quantile Plot", OutlineBox, {SetTitle("")});
	
	return(ow);
);


dt = open("$SAMPLE_DATA/Big Class.jmp");


ow = create_oneway(dt, "weight", "age");

Write();
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You could use Expr but in that case I would build the expression from few different parts&lt;/P&gt;</description>
      <pubDate>Mon, 22 Jun 2026 17:46:54 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/For-Loop-in-quot-Expr-quot-not-working/m-p/954899#M110049</guid>
      <dc:creator>jthi</dc:creator>
      <dc:date>2026-06-22T17:46:54Z</dc:date>
    </item>
  </channel>
</rss>

