<?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 Spec limits for Control Chart Builder with multiple phases and where condition in Discussions</title>
    <link>https://community.jmp.com/t5/Discussions/Spec-limits-for-Control-Chart-Builder-with-multiple-phases-and/m-p/482566#M72691</link>
    <description>&lt;P&gt;Using JSL in JMP ver. 15.2.0.&amp;nbsp; JSL code is embedded in attached table with script name = 'Control Charts'.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm struggling with behavior in nested loops when attempting to add spec limits (LSL, Target, USL) via custom graphics script for variable number of phase groupings and 'where' conditions.&amp;nbsp; My nested loops currently result in spec limits for last chart being applied to all control charts created, instead of each chart/phase/where condition receiving its respective limits.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Many thanks in advance for a nudge in the right direction!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Todd&lt;/P&gt;</description>
    <pubDate>Fri, 09 Jun 2023 16:57:51 GMT</pubDate>
    <dc:creator>Todd_Lester</dc:creator>
    <dc:date>2023-06-09T16:57:51Z</dc:date>
    <item>
      <title>Spec limits for Control Chart Builder with multiple phases and where condition</title>
      <link>https://community.jmp.com/t5/Discussions/Spec-limits-for-Control-Chart-Builder-with-multiple-phases-and/m-p/482566#M72691</link>
      <description>&lt;P&gt;Using JSL in JMP ver. 15.2.0.&amp;nbsp; JSL code is embedded in attached table with script name = 'Control Charts'.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm struggling with behavior in nested loops when attempting to add spec limits (LSL, Target, USL) via custom graphics script for variable number of phase groupings and 'where' conditions.&amp;nbsp; My nested loops currently result in spec limits for last chart being applied to all control charts created, instead of each chart/phase/where condition receiving its respective limits.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Many thanks in advance for a nudge in the right direction!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Todd&lt;/P&gt;</description>
      <pubDate>Fri, 09 Jun 2023 16:57:51 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Spec-limits-for-Control-Chart-Builder-with-multiple-phases-and/m-p/482566#M72691</guid>
      <dc:creator>Todd_Lester</dc:creator>
      <dc:date>2023-06-09T16:57:51Z</dc:date>
    </item>
    <item>
      <title>Re: Spec limits for Control Chart Builder with multiple phases and where condition</title>
      <link>https://community.jmp.com/t5/Discussions/Spec-limits-for-Control-Chart-Builder-with-multiple-phases-and/m-p/482593#M72692</link>
      <description>&lt;P&gt;Todd, JMP / JSL is a bit weird when compared to more typical programming languages -- in particular, you pretty much have to do all scope control yourself.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I've got an example here that illustrates what you're dealing with -- one might think that the below script will create a &lt;CODE class=" language-jsl"&gt;"Red"&lt;/CODE&gt; then &lt;CODE class=" language-jsl"&gt;"Blue"&lt;/CODE&gt; triangle in the graphics script, but instead only two blue triangles are created.&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;Names Default To Here( 1 );
Open( "$SAMPLE_DATA/Big Class.jmp" );
biv = Bivariate( Y( :weight ), X( :height ), FitLine );
rbiv = biv &amp;lt;&amp;lt; report;
framebox = rbiv[frame box( 1 )];

/**** Make a red triangle??? ****/
color = "Red";
framebox &amp;lt;&amp;lt; Add Graphics Script(
	Transparency( 0.5 );
	Fill Color( color );
	Polygon( [60, 72, 57], [75, 120, 120] );
);

/**** Make a blue triangle??? ****/
color = "Blue";
framebox &amp;lt;&amp;lt; Add Graphics Script(
	Transparency( 0.5 );
	Fill Color( color );
	Polygon( [60, 72, 57], [85, 130, 130] );
);&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;This happens because of how JSL handles scope -- when you use the&amp;nbsp;&lt;CODE class=" language-jsl"&gt;&amp;lt;&amp;lt;Add Graphics Script()&lt;/CODE&gt; function then it is added as a set of unevaluated statements (actually it is an unevaluated &lt;CODE class=" language-jsl"&gt;Glue()&lt;/CODE&gt; function). Any variable that exists within the &lt;CODE class=" language-jsl"&gt;&amp;lt;&amp;lt;Add Graphics Script()&lt;/CODE&gt; script will get evaluated &lt;EM&gt;only during execution&lt;/EM&gt; of the script.&amp;nbsp; When the graphics script is running (remember, it is attached to the &lt;CODE class=" language-jsl"&gt;Frame Box&lt;/CODE&gt; which is embedded in the display tree of the window) it will need to resolve each variable.&amp;nbsp; The scope resolution rules dictate that it will look into the &lt;CODE class=" language-jsl"&gt;Local&lt;/CODE&gt; scope (if it exists), the &lt;CODE class=" language-jsl"&gt;Here&lt;/CODE&gt; scope (if it exists), then the &lt;CODE class=" language-jsl"&gt;Global&lt;/CODE&gt; scope -- if it cannot find them in any of these scopes it will get replaced by an &lt;CODE class=" language-jsl"&gt;Empty()&lt;/CODE&gt; value.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;So the scripts get added to the &lt;CODE class=" language-jsl"&gt;Frame Box&lt;/CODE&gt; inside of the main script, but only executed later.&amp;nbsp; At this later point, the color variable is &lt;CODE class=" language-jsl"&gt;"Blue"&lt;/CODE&gt;, thus both triangles are blue.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The way to resolve this is to have any variables of interest get resolved &lt;EM&gt;when adding&lt;/EM&gt; the graphics script, not when executing it.&amp;nbsp; To do this use the &lt;CODE class=" language-jsl"&gt;Eval( Eval Expr() )&lt;/CODE&gt; methodology, as shown here.&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Names Default To Here( 1 );
Open( "$SAMPLE_DATA/Big Class.jmp" );
biv = Bivariate( Y( :weight ), X( :height ), FitLine );
rbiv = biv &amp;lt;&amp;lt; report;
framebox = rbiv[frame box( 1 )];

/**** Make a red triangle!!! ****/
color = "Red";
Eval( Eval Expr(
framebox &amp;lt;&amp;lt; Add Graphics Script(
	Transparency( 0.5 );
	Fill Color( Expr( color ) );
	Polygon( [60, 72, 57], [75, 120, 120] );
);
) );

/**** Make a blue triangle!!! ****/
color = "Blue";
Eval( Eval Expr(
framebox &amp;lt;&amp;lt; Add Graphics Script(
	Transparency( 0.5 );
	Fill Color( Expr( color ) );
	Polygon( [60, 72, 57], [85, 130, 130] );
);
) );&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;You need to use this method for all of your variables within the &lt;CODE class=" language-jsl"&gt;&amp;lt;&amp;lt;Add Graphics Script()&lt;/CODE&gt; function in order for them to hold the value at the time the&amp;nbsp; &lt;CODE class=" language-jsl"&gt;&amp;lt;&amp;lt;Add Graphics Script()&lt;/CODE&gt; was called.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 27 Apr 2022 22:42:43 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Spec-limits-for-Control-Chart-Builder-with-multiple-phases-and/m-p/482593#M72692</guid>
      <dc:creator>ErraticAttack</dc:creator>
      <dc:date>2022-04-27T22:42:43Z</dc:date>
    </item>
  </channel>
</rss>

