<?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: If/Loop doesn't work inside of GraphBox in Discussions</title>
    <link>https://community.jmp.com/t5/Discussions/If-Loop-doesn-t-work-inside-of-GraphBox/m-p/960575#M110205</link>
    <description>&lt;P&gt;I would suggest using Eval( Eval Expr() ).&amp;nbsp; This worked for me.&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 );

Test = Function( {width, height, showHorLines, numReferenceLines},
	{Default Local},
	Eval(
		Eval Expr(
			gb = Graph Box(
				FrameSize( Expr( width ), Expr( height ) ),
				X Scale( 0, Expr( width ) ),
				Y Scale( 0, Expr( height ) ),
				XName( "split" ),
				YName( "color" ),
				If( Expr( showHorLines ) == 1,
					Pen Color( 65 );
					For( h = 0, h &amp;lt;= Expr( numReferenceLines ), h++,
						H Line( h * Expr( height ) / Expr( numReferenceLines ) )
					);
					Pen Color( 0 );
				,

				)
			);
			win = New Window( "new window", gb );
		)
	)
);

Test( 200, 200, 1, 10 );&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Tue, 21 Jul 2026 12:50:58 GMT</pubDate>
    <dc:creator>mmarchandFSLR</dc:creator>
    <dc:date>2026-07-21T12:50:58Z</dc:date>
    <item>
      <title>If/Loop doesn't work inside of GraphBox</title>
      <link>https://community.jmp.com/t5/Discussions/If-Loop-doesn-t-work-inside-of-GraphBox/m-p/960564#M110204</link>
      <description>&lt;P&gt;Dear JMP Users, this is a simplification of a problem I am currently encountering in a script of mine:&lt;BR /&gt;&lt;BR /&gt;I am trying to encode the creation of a &lt;STRONG&gt;Graph Box&lt;/STRONG&gt; inside of a &lt;STRONG&gt;function&lt;/STRONG&gt; (here '&lt;EM&gt;Test&lt;/EM&gt;'), so that I can later loop over this process easily.&lt;BR /&gt;However, this code snippet doesn't work because the variables inside of the '&lt;EM&gt;If&lt;/EM&gt;' (&lt;EM&gt;showHorLines&lt;/EM&gt;, &lt;EM&gt;numReferenceLines&lt;/EM&gt;) don't seem to get evaluated properly, if at all. This is the case even though the other variables I am using in the arguments of the function (&lt;EM&gt;width&lt;/EM&gt;, &lt;EM&gt;height&lt;/EM&gt;) work as intended, which led me to the conclusion that it's the fault of the '&lt;EM&gt;If&lt;/EM&gt;' inside of the Graph Box.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Clear Globals();
Names Default To Here( 1 );

Test = Function({width, height, showHorLines, numReferenceLines}, {Default Local},
	gb = GraphBox(
		FrameSize(width, height),
		XScale(0, width),
		YScale(0, height),
		XName("split"),
		YName("color"),
		//[] Generate grey horizontal lines
		If(showHorLines == 1,
			PenColor(65); 
			For(h = 0, h &amp;lt;= numReferenceLines, h++, 
				HLine(h*height/numReferenceLines)
			);
			PenColor(0),
		);
	);
	win = NewWindow("new window", gb);
);

Test(200, 200, 1, 10);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Is there a way to resolve this issue, without changing the Graph Box into some other object?&lt;BR /&gt;If possible, it would be also nice for this to stay a function because I also once tried a similar approach but with Eval, EvalExpr and Expr which also didn't work and let to a similar fate.&lt;BR /&gt;&lt;BR /&gt;Best Regards&lt;/P&gt;</description>
      <pubDate>Tue, 21 Jul 2026 12:24:38 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/If-Loop-doesn-t-work-inside-of-GraphBox/m-p/960564#M110204</guid>
      <dc:creator>nozellot</dc:creator>
      <dc:date>2026-07-21T12:24:38Z</dc:date>
    </item>
    <item>
      <title>Re: If/Loop doesn't work inside of GraphBox</title>
      <link>https://community.jmp.com/t5/Discussions/If-Loop-doesn-t-work-inside-of-GraphBox/m-p/960575#M110205</link>
      <description>&lt;P&gt;I would suggest using Eval( Eval Expr() ).&amp;nbsp; This worked for me.&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 );

Test = Function( {width, height, showHorLines, numReferenceLines},
	{Default Local},
	Eval(
		Eval Expr(
			gb = Graph Box(
				FrameSize( Expr( width ), Expr( height ) ),
				X Scale( 0, Expr( width ) ),
				Y Scale( 0, Expr( height ) ),
				XName( "split" ),
				YName( "color" ),
				If( Expr( showHorLines ) == 1,
					Pen Color( 65 );
					For( h = 0, h &amp;lt;= Expr( numReferenceLines ), h++,
						H Line( h * Expr( height ) / Expr( numReferenceLines ) )
					);
					Pen Color( 0 );
				,

				)
			);
			win = New Window( "new window", gb );
		)
	)
);

Test( 200, 200, 1, 10 );&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 21 Jul 2026 12:50:58 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/If-Loop-doesn-t-work-inside-of-GraphBox/m-p/960575#M110205</guid>
      <dc:creator>mmarchandFSLR</dc:creator>
      <dc:date>2026-07-21T12:50:58Z</dc:date>
    </item>
    <item>
      <title>Re: If/Loop doesn't work inside of GraphBox</title>
      <link>https://community.jmp.com/t5/Discussions/If-Loop-doesn-t-work-inside-of-GraphBox/m-p/960611#M110207</link>
      <description>&lt;P&gt;&lt;a href="https://community.jmp.com/t5/user/viewprofilepage/user-id/91449"&gt;@nozellot&lt;/a&gt;&amp;nbsp;&amp;nbsp;quick explanation: the graphbox will continue to exist long after the function Test exits. The parameters to Test vanish when Test exits. The script attached to the graphbox won't be able to find the parameters later.&lt;/P&gt;
&lt;P&gt;&lt;a href="https://community.jmp.com/t5/user/viewprofilepage/user-id/58003"&gt;@mmarchandFSLR&lt;/a&gt;&amp;nbsp; is using my preferred solution to convert the parameters to their values. By identifying them with&lt;/P&gt;
&lt;LI-CODE lang="jsl"&gt;Expr( showHorLines )&lt;/LI-CODE&gt;
&lt;P&gt;and wrapping that with&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Eval Expr( ... )&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;which evaluates all of the expr() and leaves the evaluated answers behind, then using&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Eval( ... )&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;to run the GraphBox() function with the expression that holds constants instead of variables, you get a graph box that is not dependent on parameters that are no longer available.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 21 Jul 2026 15:07:26 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/If-Loop-doesn-t-work-inside-of-GraphBox/m-p/960611#M110207</guid>
      <dc:creator>Craige_Hales</dc:creator>
      <dc:date>2026-07-21T15:07:26Z</dc:date>
    </item>
  </channel>
</rss>

