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;