cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Try the Materials Informatics Toolkit, which is designed to easily handle SMILES data. This and other helpful add-ins are available in the JMP® Marketplace
Choose Language Hide Translation Bar
robot
Level VI

Pause Script Execution with Modal Button Box

Hi,

I need help inserting a user-controlled pause in script execution.  I am using JMP9.

I have a loop that runs though several files and runs the Nonlinear Fit platform on each.  I would like to add a button box on the Nonlinear Fit platform that will pause the script execution so that the user can confirm the fit parameters are correct before moving on to the next analysis.  What is the best way to implement this?  Some of my attempts are below.

Thanks in advance for the help!

/*

// This works, but does not pause the script execution.

nonlinearfit << Append(

  Button Box( "Click here when fit is finalized.",

  (nonlinearfit[Outline Box( 2 )] << Close( 1 ) ; nonlinearfit<< Journal ; parameters = nonlinearfit[Number Col Edit Box( 5 )] <<

  Make Into Data Table ; )

  )

);

// These do not work.

nonlinearfit << Append(

  Button Box( "Click here when fit is finalized.", << Modal,

  (nonlinearfit[Outline Box( 2 )] << Close( 1 ) ; nonlinearfit<< Journal ; parameters = nonlinearfit[Number Col Edit Box( 5 )] <<

  Make Into Data Table ; )

  )

);

nonlinearfit << Append(

  Button Box( "Click here when fit is finalized.",

  (nonlinearfit[Outline Box( 2 )] << Close( 1 ) ; nonlinearfit<< Journal ; parameters = nonlinearfit[Number Col Edit Box( 5 )] <<

  Make Into Data Table ; ) << Modal

  )

);

nonlinearfit << Append(

  Button Box( "Click here when fit is finalized.",

  (nonlinearfit[Outline Box( 2 )] << Close( 1 ) ; nonlinearfit<< Journal ; parameters = nonlinearfit[Number Col Edit Box( 5 )] <<

  Make Into Data Table ; )

  ) << Modal

);

*/

1 ACCEPTED SOLUTION

Accepted Solutions
ms
Super User (Alumni) ms
Super User (Alumni)

Re: Pause Script Execution with Modal Button Box

I am not sure how the button is to be used. The problem with a modal window is that nothing happens (scriptwise or interactively) until OK is clicket. It may also be difficult to press the button in a particular nonlinear window as new windows are created and crowding the screen. 

Below is one solution that let's the user click "Go" to complete the nonlinear fit, review results and when done click a button that both saves results (to journal and table) and moves on to the next table. Will this approach work in your setting?

bigClass = Open( "$SAMPLE_DATA/Big Class.JMP" );

bigClass << New Column( "height estimate",

     Numeric,

     Continuous,

     Format( "Best", 12 ),

     Formula( Parameter( {a = 1, b = 1, c = 1, d = 1}, a * (:weight + b) + c * :weight * Sine( d * :weight ) ) )

);

datatables = {bigClass, bigClass, BigClass}; //List of datatables to loop over

nfiles = N Items( datatables ); // number of tables

tablenr = 1;

parameters = New Table( "Parameters", New Column( "Dataset", character ) ); // A table for saving parameters from all fits

nonlin = Expr(

     nonlinearfit = New Window( "Nonlinear Fit",

          hlb = H List Box(

               Eval( datatables[tablenr] ) << Nonlinear( Y( :height ), X( :height estimate ), Newton ),

               V List Box(

                     Text Box( "Click below when fit is finalized" ),

                     Button Box( "Save results and run next table",

                          nonlinearfit[Outline Box( 2 )] << Close( 1 );

                          nonlinearfit[Outline Box( 1 )] << Journal;

                          parameters_temp = nonlinearfit[Number Col Edit Box( 3 )] << Make Into Data Table;

                          namecol = parameters_temp << New Column( "Dataset", Character, set each value( Eval( datatables[tablenr] ) << get name ) );

                          namecol << move to( first );

                          parameters << Concatenate( parameters_temp, Append to first table );

                          nonlinearfit << close window;

                          Close( parameters_temp, no save );

                          If( tablenr < nfiles,

                               tablenr++;

                               nonlin;  // Next table

                               nonlinearfit << Bring Window To Front;

                          );

                     )

               )

          )

     )

);

nonlin;

View solution in original post

3 REPLIES 3
robot
Level VI

Re: Pause Script Execution with Modal Button Box

Here is an example script to help make debugging easier.

/*

bigClass = Open( "$SAMPLE_DATA/Big Class.JMP" );

bigClass << New Column( "height estimate",

  Numeric,

  Continuous,

  Format( "Best", 12 ),

  Formula( Parameter( {a = 1, b = 1, c = 1, d = 1}, a * (:weight + b) + c * :weight * Sine( d * :weight ) ) )

);

nonlinearfit = New Window( "Nonlinear Fit", bigClass << Nonlinear( Y( :height ), X( :height estimate ), Newton ) );

nonlinearfit << Append(

  Button Box( "Click here when fit is finalized.",

  (nonlinearfit[Outline Box( 2 )] << Close( 1 ) ; nonlinearfit << Journal ; parameters = nonlinearfit[Number Col Edit Box( 3 )] <<

  Make Into Data Table ; )

  )

);

New Window( "Text Box", <<Modal, Text Box( "Wait!  Don't run this text box yet!" ), Button Box( "OK" ) );

*/

ms
Super User (Alumni) ms
Super User (Alumni)

Re: Pause Script Execution with Modal Button Box

I am not sure how the button is to be used. The problem with a modal window is that nothing happens (scriptwise or interactively) until OK is clicket. It may also be difficult to press the button in a particular nonlinear window as new windows are created and crowding the screen. 

Below is one solution that let's the user click "Go" to complete the nonlinear fit, review results and when done click a button that both saves results (to journal and table) and moves on to the next table. Will this approach work in your setting?

bigClass = Open( "$SAMPLE_DATA/Big Class.JMP" );

bigClass << New Column( "height estimate",

     Numeric,

     Continuous,

     Format( "Best", 12 ),

     Formula( Parameter( {a = 1, b = 1, c = 1, d = 1}, a * (:weight + b) + c * :weight * Sine( d * :weight ) ) )

);

datatables = {bigClass, bigClass, BigClass}; //List of datatables to loop over

nfiles = N Items( datatables ); // number of tables

tablenr = 1;

parameters = New Table( "Parameters", New Column( "Dataset", character ) ); // A table for saving parameters from all fits

nonlin = Expr(

     nonlinearfit = New Window( "Nonlinear Fit",

          hlb = H List Box(

               Eval( datatables[tablenr] ) << Nonlinear( Y( :height ), X( :height estimate ), Newton ),

               V List Box(

                     Text Box( "Click below when fit is finalized" ),

                     Button Box( "Save results and run next table",

                          nonlinearfit[Outline Box( 2 )] << Close( 1 );

                          nonlinearfit[Outline Box( 1 )] << Journal;

                          parameters_temp = nonlinearfit[Number Col Edit Box( 3 )] << Make Into Data Table;

                          namecol = parameters_temp << New Column( "Dataset", Character, set each value( Eval( datatables[tablenr] ) << get name ) );

                          namecol << move to( first );

                          parameters << Concatenate( parameters_temp, Append to first table );

                          nonlinearfit << close window;

                          Close( parameters_temp, no save );

                          If( tablenr < nfiles,

                               tablenr++;

                               nonlin;  // Next table

                               nonlinearfit << Bring Window To Front;

                          );

                     )

               )

          )

     )

);

nonlin;

robot
Level VI

Re: Pause Script Execution with Modal Button Box

Brilliant!  Thank you very much MS!