This code will find table scripts for fit model and pop them into a script window
dt = open("$SAMPLE_DATA/Big Class.jmp");
// check whether the current data table contains any scripts
// for least squares regression
lstModelNames = {}; // name of scripts
lstModelScripts = {}; // script contents
If (NTable()>0,
lstTableScripts = Current Data Table() << Get Table Script Names;
For (i=1,i<=NItems(lstTableScripts),i++,
s = Current Data Table() << Get Property(lstTableScripts[i]);
str = Char(NameExpr(s));
If (Left(str,7)!="JMP App" & Contains(str,"Standard Least Squares") & !Contains(str,"Generalized Regression"),
InsertInto(lstModelNames,lstTableScripts[i]);
InsertInto(lstModelScripts,NameExpr(s));
)
)
);
// launch script windows
For (i=1,i<=NItems(lstModelScripts),i++,
New Window(lstModelNames[i], <<Script,
Char(lstModelScripts[i])
);
);
But if they are in a script window then you have to manually make the edits. Alternatively just treat the scripts as either expressions or as strings and manipulate them in code. For example:
// run the model invisiblely and create a handle 'fm'
// that references the model object
s = lstModelScripts[1];
str = Char(NameExpr(s));
str = "fm =" || str;
SubstituteInto(str,"Fit Model(","Fit Model(Invisible,");
Eval(Parse(str));
// ensure summary of fit is available
fm << Summary Of Fit(1);
// grab the R-sq from the report window
rep = fm << Report;
ob = rep[OutlineBox("Summary of Fit")];
values = ob[NumberColBox(1)] << Get;
Rsquare = values[1];
// close the model object
rep << Close Window;
show(RSquare);
-Dave