Hi all,
I'm once again struggling with a script...
This one builds an expression. It looks ok.
I can even copy and paste it from the log file back to the script window, and if I do so, it executes correctly with expected output.
But I tried Eval(), Eval Expr(), Eval(Eval Expr()), Eval(Parse())... well that last one with even less hope than the others, but bottom line is... I just can't make it work!
Names Default To Here( 1 );
ParamsList = {
{"P1", "Parameter 1"},
{"P2", "Parameter 2"}
};
analysis = Expr(Analysis Column());
For (i=1, i<= Length(ParamsList), i++,
Insert Into(
analysis,
Substitute(
Expr(Transform Column("__Desc__", Formula(__Parameter__))),
"__Desc__", ParamsList[i][2]||" Median",
Expr(__Parameter__), Parse(":"||ParamsList[i][1]||"_Q50")
)
);
);
addRowExpr = Expr(Row Table());
Insert Into(addRowExpr, Eval Expr(analysis));
Insert Into(addRowExpr, Expr(Statistics(Median)));
addTabExpr = Expr(Add Table(Column Table(Grouping Columns(:Source))));
Insert Into(addTabExpr, Eval Expr(addRowExpr));
tabExpr = Expr(Tabulate(Set Format(Uniform Format(10,2))));
Insert Into(tabExpr, Eval Expr(addTabExpr));
show(tabExpr);
dtParams = Eval(Eval Expr(tabExpr));
I attach a "Test.jmp" file on which you can try.
The output of the "show" command is:
tabExpr = Tabulate(Set Format(Uniform Format(10, 2)), Add Table(Column Table(Grouping Columns(:Source)), Row Table(Analysis Column(Transform Column("Parameter 1 Median", Formula(:P1_Q50)), Transform Column("Parameter 2 Median", Formula(:P2_Q50))), Statistics(Median))));
And as said: if I copy-paste it back to the script window to execute that output, I get what I want!
So, how do I "evaluate" that expression?
Thanks!