<?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 Help, my script run OK in a Script Window but fail when run in a Column Formula in Discussions</title>
    <link>https://community.jmp.com/t5/Discussions/Help-my-script-run-OK-in-a-Script-Window-but-fail-when-run-in-a/m-p/807310#M98644</link>
    <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I created a script to summarize a data table by analyzing the individual statistical impact of M factors on N metrics.&lt;/P&gt;&lt;P&gt;The summary table show the matrix of N metrics (rows) with M factors (columns), with the specific impact: Mean shift, Cpk degradation, or both)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I want to add a feature to plot the distribution for each selected row with a column formula.&lt;/P&gt;&lt;P&gt;I got inspired by this post:&lt;/P&gt;&lt;P&gt;&lt;A href="https://community.jmp.com/t5/Discussions/Linking-a-cell-in-a-JMP-table-to-a-script/td-p/5171" target="_self"&gt;Linking a cell (in a JMP table) to a script?&lt;/A&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The problem is, my script works well in a New Script Window with a fixed selected row ([5] in this example), but then fail when I include the script in the :Graph column formula. I don’t understand why…&lt;/P&gt;&lt;P&gt;Could you please help me debug this?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Attached 2 tables: datatable_test.jmp with the raw data, Summary.jmp with the column formula. The idea is to click on the cell you want to plot in the :Graph column.&lt;/P&gt;&lt;P&gt;Currently the error shows: :”Illegal Reference (recursion) at row [ ]”&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="image.png" style="width: 400px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/69371iC1B89F707278BB48/image-size/medium?v=v2&amp;amp;px=400" role="button" title="image.png" alt="image.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;When I run the following script with both tables open, it works as expected (see below). But the script fails when run from the table directly (click on cell in Graph column).&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="image.png" style="width: 398px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/69372iEF0E732BD3AC730A/image-size/medium?v=v2&amp;amp;px=400" role="button" title="image.png" alt="image.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks a lot in advance,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;-Voiz&lt;SPAN class=""&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;// this script works from a Script window
// All features related to the column formula are commented
// here the row selected is row 5 : rn1 = [5]

Names Default To Here( 1 );
dt = Data Table( "datatable_test" );
dt2 = Data Table( "Summary" );
//If( Selected( Row State() ),
	Eval(
		Parse(
			rn1 = [5]/*dt2 &amp;lt;&amp;lt; get selected rows*/;
			rn = rn1[1];
			Factors = dt2 &amp;lt;&amp;lt; get column names( "string" );
			show(rn1, rn);
			Eval(
				Eval Expr(
					For( i = N Items( Factors ), i &amp;gt;= 1, i--,
						CurrCol = Column( dt2, Factors[i] );
						If(Char( CurrCol[ rn ]   ) == "Ok" | Factors[i] == "Metric"| Factors[i] == "Graph",
							Remove From( Factors, i, 1 )
						);
					)
				)
			);
			FactorA = "X( :" || Char( Factors[1] ) || ", Position( 1 ))";
			FactorB = "X(1)";
			For( j = 2, j &amp;lt;= N Items( Factors ), j++,
				FactorA = Char( FactorA ) || ",X( :" || Char( Factors[j] ) ||
				", Position( 1 ))";
				FactorB = Char( FactorB ) || ",X( " || Char( j ) || " ) ";
			);
			Show( dt2:Metric[rn], FactorA, FactorB );
			Key = dt2:Metric[rn];
			Eval Insert(
				" dt &amp;lt;&amp;lt; Graph Builder(
				Size( 534, 464 ),
				Show Control Panel( 0 ),
				Show Legend( 0 ),
				Variables(
				Y( ^Key^ ), ^FactorA^),
				Elements( Box Plot( Y, Legend( 18 ), ^FactorB^ ) ),
				SendToReport(
				Dispatch(
					{},
				
				ScaleBox,
				{Min( -0.485125992718803 ), Max( 5.53364268893602 ), Inc( 1 ),
				Minor Ticks( 0 )}
				)
				)
			) "
			);
		)
	//)
);&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Mon, 21 Oct 2024 17:57:33 GMT</pubDate>
    <dc:creator>Voizingu</dc:creator>
    <dc:date>2024-10-21T17:57:33Z</dc:date>
    <item>
      <title>Help, my script run OK in a Script Window but fail when run in a Column Formula</title>
      <link>https://community.jmp.com/t5/Discussions/Help-my-script-run-OK-in-a-Script-Window-but-fail-when-run-in-a/m-p/807310#M98644</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I created a script to summarize a data table by analyzing the individual statistical impact of M factors on N metrics.&lt;/P&gt;&lt;P&gt;The summary table show the matrix of N metrics (rows) with M factors (columns), with the specific impact: Mean shift, Cpk degradation, or both)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I want to add a feature to plot the distribution for each selected row with a column formula.&lt;/P&gt;&lt;P&gt;I got inspired by this post:&lt;/P&gt;&lt;P&gt;&lt;A href="https://community.jmp.com/t5/Discussions/Linking-a-cell-in-a-JMP-table-to-a-script/td-p/5171" target="_self"&gt;Linking a cell (in a JMP table) to a script?&lt;/A&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The problem is, my script works well in a New Script Window with a fixed selected row ([5] in this example), but then fail when I include the script in the :Graph column formula. I don’t understand why…&lt;/P&gt;&lt;P&gt;Could you please help me debug this?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Attached 2 tables: datatable_test.jmp with the raw data, Summary.jmp with the column formula. The idea is to click on the cell you want to plot in the :Graph column.&lt;/P&gt;&lt;P&gt;Currently the error shows: :”Illegal Reference (recursion) at row [ ]”&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="image.png" style="width: 400px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/69371iC1B89F707278BB48/image-size/medium?v=v2&amp;amp;px=400" role="button" title="image.png" alt="image.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;When I run the following script with both tables open, it works as expected (see below). But the script fails when run from the table directly (click on cell in Graph column).&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="image.png" style="width: 398px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/69372iEF0E732BD3AC730A/image-size/medium?v=v2&amp;amp;px=400" role="button" title="image.png" alt="image.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks a lot in advance,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;-Voiz&lt;SPAN class=""&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;// this script works from a Script window
// All features related to the column formula are commented
// here the row selected is row 5 : rn1 = [5]

Names Default To Here( 1 );
dt = Data Table( "datatable_test" );
dt2 = Data Table( "Summary" );
//If( Selected( Row State() ),
	Eval(
		Parse(
			rn1 = [5]/*dt2 &amp;lt;&amp;lt; get selected rows*/;
			rn = rn1[1];
			Factors = dt2 &amp;lt;&amp;lt; get column names( "string" );
			show(rn1, rn);
			Eval(
				Eval Expr(
					For( i = N Items( Factors ), i &amp;gt;= 1, i--,
						CurrCol = Column( dt2, Factors[i] );
						If(Char( CurrCol[ rn ]   ) == "Ok" | Factors[i] == "Metric"| Factors[i] == "Graph",
							Remove From( Factors, i, 1 )
						);
					)
				)
			);
			FactorA = "X( :" || Char( Factors[1] ) || ", Position( 1 ))";
			FactorB = "X(1)";
			For( j = 2, j &amp;lt;= N Items( Factors ), j++,
				FactorA = Char( FactorA ) || ",X( :" || Char( Factors[j] ) ||
				", Position( 1 ))";
				FactorB = Char( FactorB ) || ",X( " || Char( j ) || " ) ";
			);
			Show( dt2:Metric[rn], FactorA, FactorB );
			Key = dt2:Metric[rn];
			Eval Insert(
				" dt &amp;lt;&amp;lt; Graph Builder(
				Size( 534, 464 ),
				Show Control Panel( 0 ),
				Show Legend( 0 ),
				Variables(
				Y( ^Key^ ), ^FactorA^),
				Elements( Box Plot( Y, Legend( 18 ), ^FactorB^ ) ),
				SendToReport(
				Dispatch(
					{},
				
				ScaleBox,
				{Min( -0.485125992718803 ), Max( 5.53364268893602 ), Inc( 1 ),
				Minor Ticks( 0 )}
				)
				)
			) "
			);
		)
	//)
);&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 21 Oct 2024 17:57:33 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Help-my-script-run-OK-in-a-Script-Window-but-fail-when-run-in-a/m-p/807310#M98644</guid>
      <dc:creator>Voizingu</dc:creator>
      <dc:date>2024-10-21T17:57:33Z</dc:date>
    </item>
    <item>
      <title>Re: Help, my script run OK in a Script Window but fail when run in a Column Formula</title>
      <link>https://community.jmp.com/t5/Discussions/Help-my-script-run-OK-in-a-Script-Window-but-fail-when-run-in-a/m-p/807320#M98645</link>
      <description>&lt;P&gt;Is there a specific reason to do this with a column formula? For example having custom a window with table box and button(s) would be much easier to build and manage. Or maybe using row state handler on summary table (though I would avoid that if possible).&lt;/P&gt;</description>
      <pubDate>Mon, 21 Oct 2024 18:37:13 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Help-my-script-run-OK-in-a-Script-Window-but-fail-when-run-in-a/m-p/807320#M98645</guid>
      <dc:creator>jthi</dc:creator>
      <dc:date>2024-10-21T18:37:13Z</dc:date>
    </item>
    <item>
      <title>Re: Help, my script run OK in a Script Window but fail when run in a Column Formula</title>
      <link>https://community.jmp.com/t5/Discussions/Help-my-script-run-OK-in-a-Script-Window-but-fail-when-run-in-a/m-p/807325#M98646</link>
      <description>&lt;P&gt;Hi Jarmo,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;No specific reason, I just created my original script this way, using a data table to generate the summary.&lt;/P&gt;&lt;P&gt;I didn't think of that: opening a table box and add buttons seems a nice idea, I could modify my future version with that in mind.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;But in the meantime, do you think making the column formula work is worth it? So I can have a working version faster before the next version? I am afraid changing the structure to generate a table box instead of a data table will take me some time, as I am not very familiar with display / table box yet.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The piece of script I want to include in the Column formula is working on its own, but fail when run in the column formula. I must do something wrong but not sure what ...&lt;/P&gt;</description>
      <pubDate>Mon, 21 Oct 2024 20:44:30 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Help-my-script-run-OK-in-a-Script-Window-but-fail-when-run-in-a/m-p/807325#M98646</guid>
      <dc:creator>Voizingu</dc:creator>
      <dc:date>2024-10-21T20:44:30Z</dc:date>
    </item>
    <item>
      <title>Re: Help, my script run OK in a Script Window but fail when run in a Column Formula</title>
      <link>https://community.jmp.com/t5/Discussions/Help-my-script-run-OK-in-a-Script-Window-but-fail-when-run-in-a/m-p/807327#M98647</link>
      <description>&lt;P&gt;Edit:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I actually found out that converting a table to a display box was easy:&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;nw = New Window("Report",
	dt &amp;lt;&amp;lt; Get As Report()
);&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Report generated below&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="image.png" style="width: 400px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/69374iBE43DFB2FCDE2064/image-size/medium?v=v2&amp;amp;px=400" role="button" title="image.png" alt="image.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I didn't expect the formula to work in the report, when click on row (and it does not...).&lt;/P&gt;&lt;P&gt;But now I am not sure how you would suggest to proceed with your suggestion.&amp;nbsp;&lt;/P&gt;&lt;P&gt;(again I am not familiar yet with Display box manipulation)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks in advance&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 21 Oct 2024 21:06:17 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Help-my-script-run-OK-in-a-Script-Window-but-fail-when-run-in-a/m-p/807327#M98647</guid>
      <dc:creator>Voizingu</dc:creator>
      <dc:date>2024-10-21T21:06:17Z</dc:date>
    </item>
    <item>
      <title>Re: Help, my script run OK in a Script Window but fail when run in a Column Formula</title>
      <link>https://community.jmp.com/t5/Discussions/Help-my-script-run-OK-in-a-Script-Window-but-fail-when-run-in-a/m-p/807332#M98649</link>
      <description>&lt;P&gt;Edit 2:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I finally made the script to work, following the recommendation from Jarmo and this post:&lt;/P&gt;&lt;P&gt;&lt;A href="https://community.jmp.com/t5/Discussions/JSL-Help-with-Get-As-Report-amp-Table-Box/td-p/433697" target="_self"&gt;JSL Help with: Get As Report &amp;amp; Table Box&lt;/A&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Now when I click on a row in the report, it run the script based on the selected row, which is exactly what I needed :)&lt;/img&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="image.png" style="width: 400px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/69377i5B72F87F6AC3E4CE/image-size/medium?v=v2&amp;amp;px=400" role="button" title="image.png" alt="image.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Script below, it needs the 2 tables open that I joined in my first message&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;- voiz&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 );

dt7 = Data Table("Summary");
dt = Data Table("datatable_test");

dt7 &amp;lt;&amp;lt; clear select;
dt7 &amp;lt;&amp;lt; Clear Column Selection();

RptWin = New Window( "Data Table as report",
	Outline Box("Data Table as Report",
		dt7_Rpt = dt7 &amp;lt;&amp;lt; Get as Report(); 
	)
);

tb = dt7_Rpt[Table Box( 1 )];

tb &amp;lt;&amp;lt; Set Heading Column Borders( 1 );
tb &amp;lt;&amp;lt; Set Selectable Rows( 1 );
tb &amp;lt;&amp;lt; Set Row Change Function(
Function( {this},
	{SelRows},
	SelRows = this &amp;lt;&amp;lt; Get Selected Rows;
	If(
		N Items( SelRows ) &amp;gt; 1, Throw( "Too many items selected!\!rOnly one selection possible." ),
		N Items( SelRows ) == 1,
			SelRows = this &amp;lt;&amp;lt; Get Selected Rows;
	);
	dt7 &amp;lt;&amp;lt; Clear Select;
	rn = dt7 &amp;lt;&amp;lt; Select rows( SelRows ) &amp;lt;&amp;lt; get selected rows;
	show (rn[1], dt7:Metric[rn]);
		
	Factors = dt7 &amp;lt;&amp;lt; get column names( "string" );
			
	Eval(
		Eval Expr(
			For( i = N Items( Factors ), i &amp;gt;= 1, i--,
				CurrCol = Column( dt7, Factors[i] );
				If(Char( CurrCol[ rn[1] ]   ) == "Ok" | Factors[i] == "Metric"| Factors[i] == "Graph",
					Remove From( Factors, i, 1 )
				);
			)
		)
	);
	show (Factors);
	Try(FactorA = "X( :" || Char( Factors[1] ) || ", Position( 1 ))");
	FactorB = "X(1)";
	For( j = 2, j &amp;lt;= N Items( Factors ), j++,
		Try(FactorA = Char( FactorA ) || ",X( :" || Char( Factors[j] ) || ", Position( 1 ))");
		FactorB = Char( FactorB ) || ",X( " || Char( j ) || " ) ";
	);
	Show( dt7:Metric[rn], FactorA, FactorB );
	Key = dt7:Metric[rn];
	If (Factors != {},
		Eval(Parse(Eval Insert(
			" dt &amp;lt;&amp;lt; Graph Builder(
				Size( 534, 464 ),
				Show Control Panel( 0 ),
				Show Legend( 0 ),
				Variables(Y( ^Key^ ), ^FactorA^),
				Elements( 
					Box Plot( Y, Legend( 18 ), ^FactorB^ ), 
					Caption Box(X, Y, Legend(20), Summary Statistic( \!"N\!" ),Location( \!"Graph per factor\!" ))),
				SendToReport(
				Dispatch(
				{},
				ScaleBox,
				{Min( -0.485125992718803 ), Max( 5.53364268893602 ), Inc( 1 ),
				Minor Ticks( 0 )}
			)
			)
		) "
		))),
		Eval(Parse(Eval Insert(
			" dt &amp;lt;&amp;lt; Graph Builder(
				Size( 534, 464 ),
				Show Control Panel( 0 ),
				Show Legend( 0 ),
				Variables(Y( ^Key^ )),
				Elements( 
					Box Plot( Y, Legend( 18 )), 
					Caption Box(Y, Legend(20), Summary Statistic( \!"N\!" ))),
				SendToReport(
				Dispatch(
				{},
				ScaleBox,
				{Min( -7.06199976676385 ), Max( 26.8097086791615 ), Inc( 5 ),
				Minor Ticks( 0 )}
			)
			)
		) "
		)))	
	)
));&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 22 Oct 2024 02:51:19 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Help-my-script-run-OK-in-a-Script-Window-but-fail-when-run-in-a/m-p/807332#M98649</guid>
      <dc:creator>Voizingu</dc:creator>
      <dc:date>2024-10-22T02:51:19Z</dc:date>
    </item>
    <item>
      <title>Re: Help, my script run OK in a Script Window but fail when run in a Column Formula</title>
      <link>https://community.jmp.com/t5/Discussions/Help-my-script-run-OK-in-a-Script-Window-but-fail-when-run-in-a/m-p/807334#M98650</link>
      <description>&lt;P&gt;One more improvement I would try to do, is to get rid of Eval(Parse()) (it usually makes the script easier to debug and you don't learn bad habits). But it will take some effort and different techniques so you could work on it slowly.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I can also take a look in ~12hours so you can get an idea what you could potentially do.&lt;/P&gt;</description>
      <pubDate>Tue, 22 Oct 2024 04:19:22 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Help-my-script-run-OK-in-a-Script-Window-but-fail-when-run-in-a/m-p/807334#M98650</guid>
      <dc:creator>jthi</dc:creator>
      <dc:date>2024-10-22T04:19:22Z</dc:date>
    </item>
    <item>
      <title>Re: Help, my script run OK in a Script Window but fail when run in a Column Formula</title>
      <link>https://community.jmp.com/t5/Discussions/Help-my-script-run-OK-in-a-Script-Window-but-fail-when-run-in-a/m-p/807336#M98651</link>
      <description>&lt;P&gt;Agree. I'd go a step further and replace the &lt;FONT face="courier new,courier"&gt;Eval Insert()&lt;/FONT&gt;&amp;nbsp;as well.&lt;FONT face="courier new, courier"&gt;&lt;BR /&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Concerning the&amp;nbsp;&lt;FONT face="courier new,courier"&gt;Eval(Parse())&lt;/FONT&gt;&amp;nbsp;- you can just skip it:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="hogi_0-1729573044143.png" style="width: 400px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/69378iA4E8E9E9A9EFECD0/image-size/medium?v=v2&amp;amp;px=400" role="button" title="hogi_0-1729573044143.png" alt="hogi_0-1729573044143.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Parse expects a string as argument.&lt;/P&gt;&lt;P&gt;An expression will be evaluated and the the resulting String is parsed and returned as an expression.&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Parse(Print(1);"a"||"b")&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;So,&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Parse(Print(1);Eval Insert(Graph Builder());"a")&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;will print 1, create the graph and return a as an expression. If you are just interested in the center part, you can skip the &lt;FONT face="courier new,courier"&gt;Parse&lt;/FONT&gt;.&lt;/P&gt;&lt;P&gt;Wrapping &lt;FONT face="courier new,courier"&gt;Parse(Eval Insert())&lt;/FONT&gt; with &lt;FONT face="courier new,courier"&gt;Eval()&lt;/FONT&gt; will still evaluate it.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;On the other hand, &lt;FONT face="courier new,courier"&gt;Eval(Eval Expr())&lt;/FONT&gt; is just needed to evaluate an &lt;FONT face="courier new,courier"&gt;Expr()&lt;/FONT&gt; which is inside.&lt;/P&gt;&lt;P&gt;Without an &lt;FONT face="courier new,courier"&gt;Expr()&lt;/FONT&gt;, you can remove it from the code without harm.&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;In general, I'd propose to post a code which is based on a data set from &lt;FONT face="courier new,courier"&gt;Help/Sample Data Folder.&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;Then the code can be execute right away without the need to download files via the internet.&lt;BR /&gt;The additional benefit:&amp;nbsp; adapting the code to different inputs&amp;nbsp;often helps to understand the issue.&lt;/P&gt;&lt;P&gt;Often, when I have the right code to post the question - the question is gone : )&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="hogi_1-1729573899077.png" style="width: 400px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/69379i9FF1818AA2E4BE90/image-size/medium?v=v2&amp;amp;px=400" role="button" title="hogi_1-1729573899077.png" alt="hogi_1-1729573899077.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 22 Oct 2024 05:18:34 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Help-my-script-run-OK-in-a-Script-Window-but-fail-when-run-in-a/m-p/807336#M98651</guid>
      <dc:creator>hogi</dc:creator>
      <dc:date>2024-10-22T05:18:34Z</dc:date>
    </item>
    <item>
      <title>Re: Help, my script run OK in a Script Window but fail when run in a Column Formula</title>
      <link>https://community.jmp.com/t5/Discussions/Help-my-script-run-OK-in-a-Script-Window-but-fail-when-run-in-a/m-p/807426#M98669</link>
      <description>&lt;P&gt;This does look complicated (and it is) but this is how I would most likely approach this (it isn't the only way, you can also utilize &amp;lt;&amp;lt; add variables/&amp;lt;&amp;lt; add elements)&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Names Default To Here(1);

dt_summary = Open("$DOWNLOADS/Summary.jmp");
dt = Open("$DOWNLOADS/datatable_test.jmp");
dt &amp;lt;&amp;lt; New Column("Ones", Numeric, Nominal, Set Each Value(1));

dt_summary &amp;lt;&amp;lt; clear select;
dt_summary &amp;lt;&amp;lt; Clear Column Selection();

possible_factors = dt_summary &amp;lt;&amp;lt; get column names("string");
Remove From(possible_factors, Contains(possible_factors, "Metric"));
Remove From(possible_factors, Contains(possible_factors, "Graph"));



create_report = function({sel_row}, {Default Local},
	valid_factor_idx = Loc(dt_summary[sel_row, possible_factors], "Ok");
	valid_factors = possible_factors[valid_factor_idx];
	
	key = dt_summary[sel_row, "Metric"];

	If(N Items(valid_factors) == 0,
		valid_factors = {"Ones"};
	);

	variables_expr = Expr(Variables());
	bp_expr = Expr(Box Plot(Y, Legend(18)));
	
	dt = dt; // JMP being JMP
	For Each({valid_factor, idx}, valid_factors,
		x_expr = EvalExpr(X(Expr(Name Expr(AsColumn(dt, valid_factor))), Position(1)));
		Insert Into(variables_expr, Name Expr(x_expr));
		Insert Into(bp_expr, Eval Expr(X(Expr(idx))));
	);

	y_expr = EvalExpr(Y(Expr(Name Expr(AsColumn(dt, key)))));
	Insert Into(variables_expr, Name Expr(y_expr));
	
	gb_expr = Substitute(
		Expr(dt &amp;lt;&amp;lt; Graph Builder(
			Size(534, 464),
			Show Control Panel(0),
			Show Legend(0),
			_variables_,
			Elements(
				_boxplot_,
				Caption Box(X, Y, Legend(20), Summary Statistic("N"), Location("Graph per factor"))
			),
			SendToReport(
				Dispatch({}, ScaleBox, {Min(-7.06199976676385), Max(26.8097086791615), Inc(5), Minor Ticks(0)})
			)
		)),
		Expr(_variables_), Name Expr(variables_expr),
		Expr(_boxplot_), Name Expr(bp_expr)
	);
	gb = Eval(gb_expr);
	
	return();
);

nw = New Window("Data Table as report",
	Outline Box("Data Table as Report",
		summary_report = dt_summary &amp;lt;&amp;lt; Get as Report();
	)
);

report_tb = summary_report[Table Box(1)];
report_tb &amp;lt;&amp;lt; Set Heading Column Borders(1);
report_tb &amp;lt;&amp;lt; Set Selectable Rows(1);

report_tb &amp;lt;&amp;lt; Set Row Change Function(Function({this},
	selrows = this &amp;lt;&amp;lt; Get Selected Rows;
	If(N Items(selrows) &amp;gt; 1, 
		Throw("Too many items selected!\!rOnly one selection possible.")
	);
	create_report(selrows[1]);
));

Write();&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;After this is working, I would start thinking maybe about the user experience:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;Maybe I should use a button which would create reports for selected rows when pressed?&lt;/LI&gt;
&lt;LI&gt;Could I let user select more than one row?&lt;/LI&gt;
&lt;LI&gt;Should I create all the reports to same window in that case?&lt;/LI&gt;
&lt;LI&gt;If graph has already been created, do I need to re-create it?&lt;/LI&gt;
&lt;LI&gt;When user closes the window, should I also close the data tables?&lt;/LI&gt;
&lt;LI&gt;..&lt;/LI&gt;
&lt;/UL&gt;
&lt;LI-SPOILER&gt;&lt;BR /&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Names Default To Here(1);

dt_summary = Open("$DOWNLOADS/Summary.jmp");
dt = Open("$DOWNLOADS/datatable_test.jmp");
dt &amp;lt;&amp;lt; New Column("Ones", Numeric, Nominal, Set Each Value(1));

dt_summary &amp;lt;&amp;lt; clear select;
dt_summary &amp;lt;&amp;lt; Clear Column Selection();

possible_factors = dt_summary &amp;lt;&amp;lt; get column names("string");
Remove From(possible_factors, Contains(possible_factors, "Metric"));
Remove From(possible_factors, Contains(possible_factors, "Graph"));



create_report = function({sel_row}, {Default Local},
	valid_factor_idx = Loc(dt_summary[sel_row, possible_factors], "Ok");
	valid_factors = possible_factors[valid_factor_idx];
	
	key = dt_summary[sel_row, "Metric"];

	If(N Items(valid_factors) == 0,
		valid_factors = {"Ones"};
	);

	variables_expr = Expr(Variables());
	bp_expr = Expr(Box Plot(Y, Legend(18)));
	
	dt = dt; // JMP being JMP
	For Each({valid_factor, idx}, valid_factors,
		x_expr = EvalExpr(X(Expr(Name Expr(AsColumn(dt, valid_factor))), Position(1)));
		Insert Into(variables_expr, Name Expr(x_expr));
		Insert Into(bp_expr, Eval Expr(X(Expr(idx))));
	);

	y_expr = EvalExpr(Y(Expr(Name Expr(AsColumn(dt, key)))));
	Insert Into(variables_expr, Name Expr(y_expr));
	
	gb_expr = Substitute(
		Expr(dt &amp;lt;&amp;lt; Graph Builder(
			Size(534, 464),
			Show Control Panel(0),
			Show Legend(0),
			_variables_,
			Elements(
				_boxplot_,
				Caption Box(X, Y, Legend(20), Summary Statistic("N"), Location("Graph per factor"))
			),
			SendToReport(
				Dispatch({}, ScaleBox, {Min(-7.06199976676385), Max(26.8097086791615), Inc(5), Minor Ticks(0)})
			)
		)),
		Expr(_variables_), Name Expr(variables_expr),
		Expr(_boxplot_), Name Expr(bp_expr)
	);
	
	return(gb_expr);
);

nw = New Window("Data Table as report",
	H List Box(
		Outline Box("Data Table as Report",
			summary_report = dt_summary &amp;lt;&amp;lt; Get as Report();
		),
		Outline Box("Actions",
			Button Box("Create Reports",
				sel_rows = report_tb &amp;lt;&amp;lt; Get Selected Rows;
				lub_collector = Lineup Box(N Col(2));
				For Each({selrow}, sel_rows,
					lub_collector &amp;lt;&amp;lt; Append(create_report(selrow));
				);
				nw_graphs = New Window("Graphs",
					lub_collector
				);
				wait(0);
			),
			Button Box("Close Window", summary_report &amp;lt;&amp;lt; close window);
		)
	)
);

report_tb = summary_report[Table Box(1)];
report_tb &amp;lt;&amp;lt; Set Heading Column Borders(1);
report_tb &amp;lt;&amp;lt; Set Selectable Rows(1);

&lt;/CODE&gt;&lt;/PRE&gt;
&lt;BR /&gt;I will edit and add images here if JMP Community ever lets me do it...&lt;BR /&gt;&lt;BR /&gt;Edit: Images&lt;BR /&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="jthi_0-1729608130985.png" style="width: 400px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/69388iB83EF5FF5B6CED70/image-size/medium?v=v2&amp;amp;px=400" role="button" title="jthi_0-1729608130985.png" alt="jthi_0-1729608130985.png" /&gt;&lt;/span&gt;&lt;BR /&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="jthi_1-1729608142115.png" style="width: 400px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/69389iD7B8CD6572FEF7B9/image-size/medium?v=v2&amp;amp;px=400" role="button" title="jthi_1-1729608142115.png" alt="jthi_1-1729608142115.png" /&gt;&lt;/span&gt;&lt;/LI-SPOILER&gt;</description>
      <pubDate>Tue, 22 Oct 2024 14:42:51 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Help-my-script-run-OK-in-a-Script-Window-but-fail-when-run-in-a/m-p/807426#M98669</guid>
      <dc:creator>jthi</dc:creator>
      <dc:date>2024-10-22T14:42:51Z</dc:date>
    </item>
    <item>
      <title>Re: Help, my script run OK in a Script Window but fail when run in a Column Formula</title>
      <link>https://community.jmp.com/t5/Discussions/Help-my-script-run-OK-in-a-Script-Window-but-fail-when-run-in-a/m-p/847209#M102185</link>
      <description>&lt;P&gt;Thanks a lot Jarmo and Hogi.&lt;/P&gt;&lt;P&gt;I am replying very late, sorry for my silence, I had to focus on other priorities the last few months but now I can get back to this !&lt;/P&gt;&lt;P&gt;I will reflect on this and try your suggestions.&lt;/P&gt;&lt;P&gt;Best,&lt;/P&gt;&lt;P&gt;-Voiz&lt;/P&gt;</description>
      <pubDate>Tue, 11 Mar 2025 04:50:32 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Help-my-script-run-OK-in-a-Script-Window-but-fail-when-run-in-a/m-p/847209#M102185</guid>
      <dc:creator>Voizingu</dc:creator>
      <dc:date>2025-03-11T04:50:32Z</dc:date>
    </item>
  </channel>
</rss>

