Hi Hauli,
Just need to create result wks before the fitting loop, and write results to this wks inside the loop instead of outside?
Try this...see comments for details...
void test1()
{
uint iWksCount = Project.WorksheetPages.Count();
vector<string> vWksName(iWksCount);
int ii=0;
foreach (WorksheetPage pg in Project.WorksheetPages)
{
vWksName[ii++] = pg.GetName();
}
// Create result worksheet here
Worksheet wksResults;
wksResults.Create("C:\Documents and Settings\SunriseResults.otw");
wksResults.GetPage().Rename("Results");
// Make sure your result worksheet has enough cols to hold all parameter values
// If not, add new columns using worksheet AddCol method here
for (ii=0; ii<iWksCount; ii++)
{
Worksheet wks= vWksName[ii];
Curve crvData(wks, 0, 1);
GraphPage gpg;
gpg.Create("C:\Documents and Settings\Sunrise NRU.OTP");
gpg.Rename("Graph"+vWksName[ii]);//name Graph after Condensate
GraphLayer gly = gpg.Layers();
gly.AddPlot(crvData, IDM_PLOT_SCATTER);
gly.Rescale();
using NLSF = LabTalk.NLSF;
NLSF.Init();
NLSF.PasteToPlot(0);
NLSF.Func$="DoseResp";
NLSF.FitData$=crvData.GetName();
NLSF.Execute("parainit");
NLSF.p1=0;
NLSF.p2=100;
NLSF.p3=1.5;
NLSF.p4=-3;
NLSF.IterateEx(100);
//
// put in another iterateex statement to ensure converegence
// this is equivalent to clicking the 100Iter button another time in the GUI
NLSF.IterateEx(100);
//
//
NLSF.ParamWks("Param"+vWksName[ii]);
NLSF.End(4);
// Write wks name and parameters to result worksheet here
wksResults.SetCell(ii, 0, vWksName[ii]);
// now parameters
wksResults.SetCell(ii, 1, NLSF.p1);
wksResults.SetCell(ii, 2, NLSF.p2);
// etc, for other parameters
}
}