<?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: Eval Expression in Discussions</title>
    <link>https://community.jmp.com/t5/Discussions/Eval-Expression/m-p/444384#M69233</link>
    <description>&lt;P&gt;Thank you! &amp;nbsp;this worked perfectly.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Sun, 12 Dec 2021 13:11:29 GMT</pubDate>
    <dc:creator>lisamaley</dc:creator>
    <dc:date>2021-12-12T13:11:29Z</dc:date>
    <item>
      <title>Eval Expression</title>
      <link>https://community.jmp.com/t5/Discussions/Eval-Expression/m-p/444237#M69213</link>
      <description>&lt;P&gt;I am trying to have the user enter several variables, once those variables are deemed ok, then the ok button goes from greyed out to active. &amp;nbsp; I got this working. &amp;nbsp;What I do not have working is the Eval Expr (outputs). &amp;nbsp;This is just a simple thing just to make sure I have this working before I do the calculations. When I run the script, here is a screen shot, the OK button is greyed out:&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="lisamaley_0-1639166737106.png" style="width: 400px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/38322i8C3A5FE44542F4A6/image-size/medium?v=v2&amp;amp;px=400" role="button" title="lisamaley_0-1639166737106.png" alt="lisamaley_0-1639166737106.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;Then I put plausible values and the ok button shows active after I click the verify inputs:&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="lisamaley_1-1639166790718.png" style="width: 400px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/38323iB06ECB60F7B3DE46/image-size/medium?v=v2&amp;amp;px=400" role="button" title="lisamaley_1-1639166790718.png" alt="lisamaley_1-1639166790718.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;But it is not running my expression and creating the table. &amp;nbsp;What &amp;nbsp;am I doing wrong? &amp;nbsp;I am on JMP 16.0 Pro. &amp;nbsp;Like I said I did something very simple like create a table just to make sure my script is working before I do a deep dive to what I really need. &amp;nbsp;&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( 0 );

Clear Log();

w = New Window( "Variables", &amp;nbsp;

    &amp;lt;&amp;lt;modal, 

    Border Box( top( 20 ), bottom( 20 ), Left( 20 ), Right( 20 ), &amp;nbsp;
        V List Box( // V and H lists nest to organize the display boxes

            H Center Box( Text Box( "Enter the Variables for the Calculations" ) ), // a second title, centered

            Spacer Box( size( 1, 30 ) ), &amp;nbsp;

            H List Box( Text Box( "α: " ), alpha_ent = Number Edit Box() ), 

            Spacer Box( size( 1, 30 ) ), &amp;nbsp;

            H List Box( Text Box( "β: " ), beta_ent = Number Edit Box() ), 

            Spacer Box( size( 1, 30 ) ), &amp;nbsp;

            H List Box( Text Box( "N: " ), N_ent = Number Edit Box() ), 

            Spacer Box( size( 1, 30 ) ), &amp;nbsp;

            H List Box( Text Box( "%: " ), Percent_ent = Number Edit Box() ), 

            Spacer Box( size( 1, 30 ) ), &amp;nbsp;

            H List Box( Text Box( "p0: " ), p0_ent = Number Edit Box() ), 

            Spacer Box( size( 1, 30 ) ), &amp;nbsp;

            H Center Box(&amp;nbsp;

                Button Box( "Verify Inputs", // this script runs when the button is pressed...

                    alpha = alpha_ent &amp;lt;&amp;lt; get;

                    beta = beta_ent &amp;lt;&amp;lt; get;

                    N = N_ent &amp;lt;&amp;lt; get;

                    percent = percent_ent &amp;lt;&amp;lt; get;

                    p0 = p0_ent &amp;lt;&amp;lt; get;

                    i = 1;

                    DOEN = 0;

                    For( i = 1, i &amp;lt; 10, i++, 
                        If( 2 ^ i == N, 

                            DOEN = DOEN + 1
                        )
                    );

                    If(
                        Abs( alpha ) &amp;gt;= 1 | alpha == 0, 
                            alphaw = New Window( "Error!",
                                &amp;lt;&amp;lt;modal,
                                Text Box(
                                    "Alpha needs to be between 0 and 1, please fix and try again"
                                ),

                            ), &amp;nbsp;

                        Abs( beta ) &amp;gt;= 1 | beta == 0, 
                            betaw = New Window( "Error!",
                                &amp;lt;&amp;lt;modal,
                                Text Box(
                                    "Beta needs to be between 0 and 1, please fix and try again"
                                ),

                            ), &amp;nbsp;

                        DOEN == 0, 
                            nw = New Window( "Error!", 

                                &amp;lt;&amp;lt;modal, 

                                Text Box(
                                    "N should be 2\!U1D3A, do not include centerpoints or repeats with N, please fix and try again"
                                ), &amp;nbsp;
                            ), &amp;nbsp;

                        Abs( percent ) &amp;gt; 90 | percent == 0, 
                            percentw = New Window( "Error!", 

                                &amp;lt;&amp;lt;modal, 

                                Text Box(
                                    "The percent needs to be between 0 and 90%, please fix and try again"
                                ), &amp;nbsp;
                            ), &amp;nbsp;

                        Abs( p0 ) &amp;gt; 0.90 | p0 == 0, 
                            p0w = New Window( "Error!",
                                &amp;lt;&amp;lt;modal,
                                Text Box(
                                    "The p0 needs to be between 0 and 0.90, please fix and try again"
                                ),

                            )

                    );

                    If(

                        Abs( alpha ) &amp;gt;= 1 | Abs( beta ) &amp;gt;= 1 | DOEN == 0 |
                        Abs( percent ) &amp;gt; 90 | percent == 0 | Abs( p0 ) &amp;gt; 0.90 | p0 ==
                        0 | alpha == 0 | beta == 0, bb &amp;lt;&amp;lt; Enable( 0 ), 

                        bb &amp;lt;&amp;lt; Enable( 1 ),
                            Eval Expr( output )

                    );
                )
            ), 

            bb = Button Box( "OK" ), 

            bb &amp;lt;&amp;lt; Enable( 0 );
        )
    )
);

Show( alpha );
Show( beta );
Show( DOEN );
Show( percent );
Show( p0 );

output = Expr(

    dt = New Table( "Test Table",
        New Column( "a", Set Values( {alpha, beta, N, percent, p0} ) )
    );

    w &amp;lt;&amp;lt; closeWindow;

);&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, 09 Jun 2023 18:07:11 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Eval-Expression/m-p/444237#M69213</guid>
      <dc:creator>lisamaley</dc:creator>
      <dc:date>2023-06-09T18:07:11Z</dc:date>
    </item>
    <item>
      <title>Re: Eval Expression</title>
      <link>https://community.jmp.com/t5/Discussions/Eval-Expression/m-p/444256#M69214</link>
      <description>&lt;P&gt;I think you should be able to just get rid of the eval expr(). If you just do output, it will eval. You could also just do Eval(output).&amp;nbsp; EvalExpr is more for creating dynamic expressions.&amp;nbsp; here's the bit from the scripting index.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;EvalExpr returns a copy of the expression with each Expr() clause within x replaced with it's evaluated value&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;So&amp;nbsp;&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;Eval Expr( Length( Expr( "X" || Char( 12 ) ) ) );&amp;nbsp;//&amp;nbsp;returns&amp;nbsp;Length("X12")&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;If you wanted to evaluate it you'd have to do&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Eval(Eval Expr( Length( Expr( "X" || Char( 12 ) ) ) ));&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;but you're just trying to evaluate an expression I think so you probably don't need evalexpr()&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 10 Dec 2021 21:14:55 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Eval-Expression/m-p/444256#M69214</guid>
      <dc:creator>vince_faller</dc:creator>
      <dc:date>2021-12-10T21:14:55Z</dc:date>
    </item>
    <item>
      <title>Re: Eval Expression</title>
      <link>https://community.jmp.com/t5/Discussions/Eval-Expression/m-p/444258#M69216</link>
      <description>&lt;P&gt;Move output expression before creation of w and create the output when OK button is pressed.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-SPOILER&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Names Default To Here(0);

Clear Log();

output = Expr(
	dt = New Table("Test Table", New Column("a", Set Values({alpha, beta, N, percent, p0})));
	bb &amp;lt;&amp;lt; click;
);

w = New Window("Variables",  
	&amp;lt;&amp;lt;modal, 
	Border Box(top(20), bottom(20), Left(20), Right(20),
		V List Box( // V and H lists nest to organize the display boxes
			H Center Box(Text Box("Enter the Variables for the Calculations")), // a second title, centered
			Spacer Box(size(1, 30)),  
			H List Box(Text Box("α: "), alpha_ent = Number Edit Box()), 
			Spacer Box(size(1, 30)),  
			H List Box(Text Box("β: "), beta_ent = Number Edit Box()), 
			Spacer Box(size(1, 30)),  
			H List Box(Text Box("N: "), N_ent = Number Edit Box()), 
			Spacer Box(size(1, 30)),  
			H List Box(Text Box("%: "), Percent_ent = Number Edit Box()), 
			Spacer Box(size(1, 30)),  
			H List Box(Text Box("p0: "), p0_ent = Number Edit Box()), 
			Spacer Box(size(1, 30)),  
			H Center Box( 
				Button Box("Verify Inputs", // this script runs when the button is pressed...
					alpha = alpha_ent &amp;lt;&amp;lt; get;
					beta = beta_ent &amp;lt;&amp;lt; get;
					N = N_ent &amp;lt;&amp;lt; get;
					percent = percent_ent &amp;lt;&amp;lt; get;
					p0 = p0_ent &amp;lt;&amp;lt; get;
					i = 1;
					DOEN = 0;
					For(i = 1, i &amp;lt; 10, i++,
						If(2 ^ i == N, 
							DOEN = DOEN + 1
						)
					);
					If(
						Abs(alpha) &amp;gt;= 1 | alpha == 0,
							alphaw = New Window("Error!",
								&amp;lt;&amp;lt;modal,
								Text Box("Alpha needs to be between 0 and 1, please fix and try again"), 

							),  
						Abs(beta) &amp;gt;= 1 | beta == 0,
							betaw = New Window("Error!",
								&amp;lt;&amp;lt;modal,
								Text Box("Beta needs to be between 0 and 1, please fix and try again"), 

							),  
						DOEN == 0,
							nw = New Window("Error!", 

								&amp;lt;&amp;lt;modal, 

								Text Box(
									"N should be 2\!U1D3A, do not include centerpoints or repeats with N, please fix and try again"
								),

							),  

						Abs(percent) &amp;gt; 90 | percent == 0,
							percentw = New Window("Error!", 

								&amp;lt;&amp;lt;modal, 

								Text Box("The percent needs to be between 0 and 90%, please fix and try again"),
							),  
						Abs(p0) &amp;gt; 0.90 | p0 == 0,
							p0w = New Window("Error!",
								&amp;lt;&amp;lt;modal,
								Text Box("The p0 needs to be between 0 and 0.90, please fix and try again"), 

							)

					);
					If(Abs(alpha) &amp;gt;= 1 | Abs(beta) &amp;gt;= 1 | DOEN == 0 | Abs(percent) &amp;gt; 90 | percent == 0 | Abs(p0) &amp;gt; 0.90 | p0 == 0 | alpha == 0 | beta == 0, 
						bb &amp;lt;&amp;lt; Enable(0),
						bb &amp;lt;&amp;lt; Enable(1),
						write(); //not sure why this is needed here
					);
				)
			), 
			bb = Button Box("OK", output, &amp;lt;&amp;lt; enable(0))
		)
	)
);

Show(alpha);
Show(beta);
Show(DOEN);
Show(percent);
Show(p0);&lt;/CODE&gt;&lt;/PRE&gt;&lt;/LI-SPOILER&gt;&lt;P&gt;And because you are using Modal you could also just create the new table after modal has been closed because the script won't continue execution before modal has been closed.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here is one example how you could refactor the code a bit if you want to (you can also "force" min/max values to Number Edit Box with &amp;lt;&amp;lt; Set Minimum and &amp;lt;&amp;lt; Set Maximum). This allows you to also show all error messages in the verifying step if you want to:&lt;/P&gt;&lt;LI-SPOILER&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Names Default To Here(0);
Clear Log();

validator = function({alpha, beta, N, percent, p0}, {Default Local}, //could also be expression, but this way you avoid creating unnecessary variables
	DOEN = 0;
	For(i = 1, i &amp;lt; 10, i++,
		If(2 ^ i == N, 
			DOEN = DOEN + 1
		)
	);
	error_list = {};
	If(Abs(alpha) &amp;gt;= 1 | alpha == 0,
		Insert Into(error_list,"Alpha needs to be between 0 and 1, please fix and try again");
	);
	If(Abs(beta) &amp;gt;= 1 | beta == 0,

		Insert Into(error_list,"Beta needs to be between 0 and 1, please fix and try again");
	);
	If(DOEN == 0,
		Insert Into(error_list,"N should be 2\!U1D3A, do not include centerpoints or repeats with N, please fix and try again");
	);
	If(Abs(percent) &amp;gt; 90 | percent == 0,
		Insert Into(error_list,"The percent needs to be between 0 and 90%, please fix and try again");
	);
	If(Abs(p0) &amp;gt; 0.90 | p0 == 0,
		Insert Into(error_list,"The p0 needs to be between 0 and 0.90, please fix and try again");
	);
	If(N Items(error_list) &amp;gt; 0,
		nw = New Window( "Error!", &amp;lt;&amp;lt;modal, &amp;lt;&amp;lt;Set Window Icon("ErrorSmall"),
			Text Box(Concat Items(error_list, "\!N"))
		);
		0;
	,
		1;
	);
);


w = New Window("Variables", 
	&amp;lt;&amp;lt;modal, 
	&amp;lt;&amp;lt; return result,
	&amp;lt;&amp;lt; On Validate(
		validator(alpha_ent &amp;lt;&amp;lt; get, beta_ent &amp;lt;&amp;lt; get, N_ent &amp;lt;&amp;lt; get, percent_ent &amp;lt;&amp;lt; get,p0_ent &amp;lt;&amp;lt; get)
	),
	Border Box(top(20), bottom(20), Left(20), Right(20),
		V List Box( // V and H lists nest to organize the display boxes
			H Center Box(Text Box("Enter the Variables for the Calculations")), // a second title, centered
			Spacer Box(size(1, 30)),  
			H List Box(Text Box("α: "), alpha_ent = Number Edit Box()), 
			Spacer Box(size(1, 30)),  
			H List Box(Text Box("β: "), beta_ent = Number Edit Box()), 
			Spacer Box(size(1, 30)),  
			H List Box(Text Box("N: "), N_ent = Number Edit Box()), 
			Spacer Box(size(1, 30)),  
			H List Box(Text Box("%: "), Percent_ent = Number Edit Box()), 
			Spacer Box(size(1, 30)),  
			H List Box(Text Box("p0: "), p0_ent = Number Edit Box()), 
			Spacer Box(size(1, 30)),  
			H List BOx(Button Box("OK"), Button Box("Cancel"));
		)
	)
);


If(w["Button"] == 1,
	dt = New Table("Test Table", New Column("a", Set Values({w["alpha_ent"], w["beta_ent"], w["N_ent"], w["Percent_ent"], w["p0_ent"]})));
, //else
	stop();
);

Show(w);&lt;/CODE&gt;&lt;/PRE&gt;&lt;/LI-SPOILER&gt;&lt;P&gt;Edit:&lt;/P&gt;&lt;P&gt;Some options for display box usage:&lt;/P&gt;&lt;LI-SPOILER&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Names Default To Here(0);
Clear Log();

validator = function({alpha, beta, N, percent, p0}, {Default Local},
	error_list = {};
	DOEN = 0;
	For(i = 1, i &amp;lt; 10, i++,
		If(2 ^ i == N, 
			DOEN = DOEN + 1
		)
	);
	If(Abs(alpha) &amp;gt;= 1 | alpha == 0,
		Insert Into(error_list,"Alpha needs to be between 0 and 1, please fix and try again");
	);
	If(Abs(beta) &amp;gt;= 1 | beta == 0,
		Insert Into(error_list,"Beta needs to be between 0 and 1, please fix and try again");
	);
	If(DOEN == 0,
		Insert Into(error_list,"N should be 2\!U1D3A, do not include centerpoints or repeats with N, please fix and try again");
	);
	If(Abs(percent) &amp;gt; 90 | percent == 0,
		Insert Into(error_list,"The percent needs to be between 0 and 90%, please fix and try again");
	);
	If(Abs(p0) &amp;gt; 0.90 | p0 == 0,
		Insert Into(error_list,"The p0 needs to be between 0 and 0.90, please fix and try again");
	);
	If(N Items(error_list) &amp;gt; 0,
		nw = New Window( "Error!", &amp;lt;&amp;lt;modal, &amp;lt;&amp;lt;Set Window Icon("ErrorSmall"),
			Text Box(Concat Items(error_list, "\!N"))
		);
		return(0);
	);
	return(1);
);

w = New Window("Variables", 
	&amp;lt;&amp;lt;modal, 
	&amp;lt;&amp;lt; return result,
	&amp;lt;&amp;lt; On Validate(
		validator(alpha_ent &amp;lt;&amp;lt; get, beta_ent &amp;lt;&amp;lt; get, N_ent &amp;lt;&amp;lt; get, percent_ent &amp;lt;&amp;lt; get,p0_ent &amp;lt;&amp;lt; get)
	),
	Border Box(top(20), bottom(20), Left(20), Right(20),
		V List Box( align("center"),
			Text Box("Enter the Variables for the Calculations"),
				Lineup Box(N Col(2), Spacing(5),
					Text Box("α: "), alpha_ent = Number Edit Box(),
					Text Box("β: "), beta_ent = Number Edit Box(),
					Text Box("N: "), N_ent = Number Edit Box(),
					Text Box("%: "), Percent_ent = Number Edit Box(),
					Text Box("p0: "), p0_ent = Number Edit Box()
				),
				Spacer Box(Size(0,10)),
				Panel Box("Press OK to run",H List Box(Button Box("OK"), Button Box("Cancel"))
			),
			
		)
	)
);

If(w["Button"] == 1,
	dt = New Table("Test Table", New Column("a", Set Values({w["alpha_ent"], w["beta_ent"], w["N_ent"], w["Percent_ent"], w["p0_ent"]})));
, //else
	stop();
);

Show(w);&lt;/CODE&gt;&lt;/PRE&gt;&lt;/LI-SPOILER&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, 10 Dec 2021 21:39:26 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Eval-Expression/m-p/444258#M69216</guid>
      <dc:creator>jthi</dc:creator>
      <dc:date>2021-12-10T21:39:26Z</dc:date>
    </item>
    <item>
      <title>Re: Eval Expression</title>
      <link>https://community.jmp.com/t5/Discussions/Eval-Expression/m-p/444382#M69232</link>
      <description>&lt;P&gt;&amp;nbsp;I tried Eval (output) first and it did not work, so I tried Eval expr() second. &amp;nbsp; I tried output by itself and it did not work. &amp;nbsp;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 12 Dec 2021 13:05:44 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Eval-Expression/m-p/444382#M69232</guid>
      <dc:creator>lisamaley</dc:creator>
      <dc:date>2021-12-12T13:05:44Z</dc:date>
    </item>
    <item>
      <title>Re: Eval Expression</title>
      <link>https://community.jmp.com/t5/Discussions/Eval-Expression/m-p/444384#M69233</link>
      <description>&lt;P&gt;Thank you! &amp;nbsp;this worked perfectly.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 12 Dec 2021 13:11:29 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Eval-Expression/m-p/444384#M69233</guid>
      <dc:creator>lisamaley</dc:creator>
      <dc:date>2021-12-12T13:11:29Z</dc:date>
    </item>
  </channel>
</rss>

