User-defined fit function

Hi,
I have been using Igor for a couple of years now, but I am new to Igor programming. I would like to input a new user-defined function into the curve fitting window. The function is of the form: Integrate1D(OtherFunction, x_min, x_max).
The problem occurs because the independent variables and fit coefficients are defined in OtherFunction and it appears that curve fitting expects these to defined explicitly in the function typed into the window i.e. Integrate1D(OtherFunction, x_min, x_max). Is there a way to get Igor to recognize the information in OtherFunction or get that information into Integrate1D?
Thanks,
DW
DW-

Since Integrate1D lacks a way to pass a coefficient wave or other parameters via the Integrate1D function, you have to use globals to do the job. Here's an example of a fit function that uses Integrate1D:
Function Integrand(E)
    Variable E
   
    NVAR A, B, C, nn
   
    return (A*(2.4 - E + nn/2)*exp(-((E+B-nn)^2/C)))/(1+exp(E/0.0257))
end

Function TheFitFunc(w,n) : FitFunc
    Wave w
    Variable n

    //CurveFitDialog/ These comments were created by the Curve Fitting dialog. Altering them will
    //CurveFitDialog/ make the function less convenient to work with in the Curve Fitting dialog.
    //CurveFitDialog/ Equation:
    //CurveFitDialog/ Variable/G A = AA
    //CurveFitDialog/ Variable/G B = BB
    //CurveFitDialog/ Variable/G C = CC
    //CurveFitDialog/ Variable/G nn = n
    //CurveFitDialog/
    //CurveFitDialog/ f(n) = Integrate1D(Integrand, -10, 10,2,0)
    //CurveFitDialog/ End of Equation
    //CurveFitDialog/ Independent Variables 1
    //CurveFitDialog/ n
    //CurveFitDialog/ Coefficients 3
    //CurveFitDialog/ w[0] = AA
    //CurveFitDialog/ w[1] = BB
    //CurveFitDialog/ w[2] = CC

    Variable/G A = w[0]
    Variable/G B = w[1]
    Variable/G C = w[2]
    Variable/G nn = n
   
    return Integrate1D(Integrand, -10, 10,2,0)
End

Note Variable/G creates a global variable in the fitting function; NVAR in the integrand function connects to those globals.

John Weeks
WaveMetrics, Inc.
support@wavemetrics.com