I think the script below just confirms the behaviour you have found. It looks like, in such cases, 'setScript' adds to the predefined script (which seems reasonable), but it appears to prepend rather than append:
NamesDefaultToHere(1);
// Test table
dt = New Table( "Simulate",
Add Rows( 5 ),
New Column( "x",
Numeric,
"Continuous",
Format( "Best", 12 ),
Set Values( [1, 2, 3, 4, 5] )
),
New Column( "y",
Numeric,
"Continuous",
Format( "Best", 12 ),
Formula( :x + Random Normal( 0, 0.1 ) )
)
);
// Fit Model
fm = dt << Fit Model(
Y( :y ),
Effects( :x ),
Personality( "Standard Least Squares" ),
Emphasis( "Effect Leverage" ),
Run(
Profiler(
1,
Confidence Intervals( 1 ),
Term Value( x( 3, Lock( 0 ), Show( 1 ) ) ),
Simulator(
1,
Factors( x << Random( Normal( 3, 0.8 ) ) ),
Responses( y << No Noise )
)
),
:y << {Lack of Fit( 0 ), Plot Actual by Predicted( 1 ), Plot Residual by Predicted( 1 ), Plot Effect Leverage( 1 )}
)
);
// Define a sample script
doSomething =
Expr(
Beep();
For(i=1, i<=NTable(), i++, Print(i, DataTable(i) << getName));
);
// Assign the sample script to the button (JMP seems to prepend to the script that's already there?)
Report(fm)[ButtonBox(5)] << setScript(doSomething);
Maybe send this thread to support@jmp.com to get a definitive answer?