Subscribe Bookmark RSS Feed

Insert Expression into Table New Script

robot

Community Trekker

Joined:

Feb 27, 2012

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^;

)" );

1 ACCEPTED SOLUTION

Accepted Solutions
julian

Staff

Joined:

Jun 25, 2014

Solution

Hi 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

2 REPLIES
julian

Staff

Joined:

Jun 25, 2014

Solution

Hi 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

robot

Community Trekker

Joined:

Feb 27, 2012

Thank you, Julian.  That works.