# 2.5.1.9 From Nonlinear Fitter

The Nonlinear Fitter has a Script After Fitting section on the Code page of the NLFit dialog. This can be useful if you want to always do something immediately after a fit. As an example, you could access the fit parameter values to do further calculations or accumulate results for further analysis.

In this example, the Script After Fitting section adds the name of the fit dataset and the calculated peak center to a Workbook named GaussResults:

// This creates a new book only the first time
if(exist(GaussResults)!=2)
{
newbook name:=GaussResults sheet:=1 option:=1 chkname:=1;
GaussResults!wks.col1.name$= Dataset; GaussResults!wks.col2.name$= PeakCenter;
}

// Get the tree from the last Report Sheet (this fit)
getresults iw:=__REPORT$; // Assign ranges to the two columns in 'GaussResults' range ra1 = [GaussResults]1!1; range ra2 = [GaussResults]1!2; // Get the current row size and increment by 1 size = ra1.GetSize(); size++; // Write the Input data range in first column ra1[size]$ = ResultsTree.Input.R2.C2\$;
// and the Peak Center value in the second
ra2[size] = ResultsTree.Parameters.xc.Value;