Insert Expression into Table New Script<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />Hi,
I would like to create an expression, that is both evaluated when the script is initially run, and saved as a table script for later. I have tried different combinations of Eval, Eval Insert, and Parse, but I am unable to get it to work (this is probably due to my poor understanding of these functions). What is the best way to do this? I am using JMP11.
Thanks!
bigClass = Open( "$SAMPLE_DATA/Big Class.jmp" );
// Create expression.
HbyW = Expr( Bivariate( Y( :height ), X( :weight ) ) );
HbyW; // Run expression.
// Save expression to table for later.
Eval Insert( "bigClass << New Script(\!"HbyW\!",
^HbyW^;
)" );
Re: Insert Expression into Table New ScriptThank you, Julian. That works.
Re: Insert Expression into Table New ScriptHi robot,
EvalInsert will return a string with the substituted text, but that string needs to be converted to an expression, then evaluated. This is where parse() and eval() are needed, respectively. Here is your script with eval(parse()) added when you want to save the script, and I changed around the initial declaration of the platform to be a string, not an expression. This is needed so that you can include the literal string text in the saved script when you call HbyW with EvalInsert. To run this (before saving the script) I also added Eval(Parse() around the first run.
bigClass = Open( "$SAMPLE_DATA/Big Class.jmp" );
// Create string for platform call.
HbyW = "Bivariate( Y( :height ), X( :weight ) )";
Eval(Parse(HbyW)); // Parse string, then evaluate
// Save expression to table for later.
Eval(
Parse(
Eval Insert( "bigClass << New Script(\!"HbyW\!", ^HbyW^; )" )
)
);
I hope this helps!
julian
Re: Insert Expression into Table New ScriptJulian, what do you do if there are quoted expressions within the Bivariate function? I am using Graph Builder where there are quoted strings within the function and the Parse stops at the first one of them.
Thanks
Re: Insert Expression into Table New ScriptName Expr is what you're looking for.
bigClass = Open( "$SAMPLE_DATA/Big Class.jmp" );
// Create expression.
HbyW = Expr( Bivariate( Y( :height ), X( :weight ) ) );
HbyW; // Run expression.
// Save expression to table for later.
Eval( Eval Expr(
bigClass << New Script( "HbyW", Expr( Name Expr( HbyW ) ) );
) );