Eval ExpressionI 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. I got this working. What I do not have working is the Eval Expr (outputs). 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:

Then I put plausible values and the ok button shows active after I click the verify inputs:

But it is not running my expression and creating the table. What am I doing wrong? I am on JMP 16.0 Pro. 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.
Names Default To Here( 0 );
Clear Log();
w = New Window( "Variables",
<<MODAL>= 1 | alpha == 0,
alphaw = New Window( "Error!",
<<MODAL>= 1 | beta == 0,
betaw = New Window( "Error!",
<<MODAL> 90 | percent == 0,
percentw = New Window( "Error!",
<<MODAL> 0.90 | p0 == 0,
p0w = New Window( "Error!",
<<MODAL>= 1 | Abs( beta ) >= 1 | DOEN == 0 |
Abs( percent ) > 90 | percent == 0 | Abs( p0 ) > 0.90 | p0 ==
0 | alpha == 0 | beta == 0, bb << Enable( 0 ),
bb << Enable( 1 ),
Eval Expr( output )
);
)
),
bb = Button Box( "OK" ),
bb << 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 << closeWindow;
);</MODAL></MODAL></MODAL></MODAL></MODAL>
macOSScriptingRe: Eval ExpressionI 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). EvalExpr is more for creating dynamic expressions. here's the bit from the scripting index.
EvalExpr returns a copy of the expression with each Expr() clause within x replaced with it's evaluated value
So
Eval Expr( Length( Expr( "X" || Char( 12 ) ) ) ); // returns Length("X12")
If you wanted to evaluate it you'd have to do
Eval(Eval Expr( Length( Expr( "X" || Char( 12 ) ) ) ));
but you're just trying to evaluate an expression I think so you probably don't need evalexpr()
Re: Eval ExpressionMove output expression before creation of w and create the output when OK button is pressed.
View more...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 << click;
);
w = New Window("Variables",
<<MODAL>= 1 | alpha == 0,
alphaw = New Window("Error!",
<<MODAL>= 1 | beta == 0,
betaw = New Window("Error!",
<<MODAL> 90 | percent == 0,
percentw = New Window("Error!",
<<MODAL> 0.90 | p0 == 0,
p0w = New Window("Error!",
<<MODAL>= 1 | Abs(beta) >= 1 | DOEN == 0 | Abs(percent) > 90 | percent == 0 | Abs(p0) > 0.90 | p0 == 0 | alpha == 0 | beta == 0,
bb << Enable(0),
bb << Enable(1),
write(); //not sure why this is needed here
);
)
),
bb = Button Box("OK", output, << enable(0))
)
)
);
Show(alpha);
Show(beta);
Show(DOEN);
Show(percent);
Show(p0);</MODAL></MODAL></MODAL></MODAL></MODAL> 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.
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 << Set Minimum and << Set Maximum). This allows you to also show all error messages in the verifying step if you want to:
View more...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 < 10, i++,
If(2 ^ i == N,
DOEN = DOEN + 1
)
);
error_list = {};
If(Abs(alpha) >= 1 | alpha == 0,
Insert Into(error_list,"Alpha needs to be between 0 and 1, please fix and try again");
);
If(Abs(beta) >= 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) > 90 | percent == 0,
Insert Into(error_list,"The percent needs to be between 0 and 90%, please fix and try again");
);
If(Abs(p0) > 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) > 0,
nw = New Window( "Error!", <<MODAL></MODAL>Edit:
Some options for display box usage:
View more...Names Default To Here(0);
Clear Log();
validator = function({alpha, beta, N, percent, p0}, {Default Local},
error_list = {};
DOEN = 0;
For(i = 1, i < 10, i++,
If(2 ^ i == N,
DOEN = DOEN + 1
)
);
If(Abs(alpha) >= 1 | alpha == 0,
Insert Into(error_list,"Alpha needs to be between 0 and 1, please fix and try again");
);
If(Abs(beta) >= 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) > 90 | percent == 0,
Insert Into(error_list,"The percent needs to be between 0 and 90%, please fix and try again");
);
If(Abs(p0) > 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) > 0,
nw = New Window( "Error!", <<MODAL></MODAL>
Re: Eval Expression I tried Eval (output) first and it did not work, so I tried Eval expr() second. I tried output by itself and it did not work.