Using Funcfit in a procedure with loops!

Hello there, the question is in the title. I am attempting to make a procedure that will fit a user defined function, namely, a modified Error Function, to a piece of data, and then take the fitted coefficients, plug them into the equation of the Erf and get a nice smooth fit graph.
wave coeffs
Coeffs[0]=(v_max)/2    //these coeffs are the initial guesses
Coeffs[1]=v_max
Coeffs[2]=numpnts(fittederf)/2
Coeffs[3]=numpnts(fittederf)/4
variable m=0


Funcfit/q ErrorFunction,Coeffs,FittedErf   //fitting command with proper locations of waves

Make/o/n=(numpnts(fittederf)*10) SmoothERF= Coeffs[0]+Coeffs[1]*(Erf((Coeffs[2]-(x/10))/(Abs(Coeffs[3])*sqrt(2)))  //making a new wave with 10x points, but overall same domain
My issue is that i believe the coefficients that i am using above to define SmoothERF are just my initial guesses, not the properly fit ones. I was under the impression that a wave called W_coef would be created with the correct fit coefficients. This is what other posts say, and i have experienced it with the curvefit function, AND when i use this fit function from the Analysis>curvefitting tab, W_coef will be created with best-fit coefficients. I'm sure I am missing something obvious here, but does anyone have a suggestion on this? Also, unless i do the second part where i put the function there, it doesn't output anything...
Your function is using the wave Coeffs and providing it to the call to FuncFit, so you won't get W_coefs. The way you have written this, you are fitting a function "ErrorFunction" using wave "Coeffs" to fit the data in the wave "FittedErf". You can get Igor to make a smooth fit curve wave by adding the /D flag at the end of the FuncFit command. John Weeks WaveMetrics, Inc. support@wavemetrics.com
O thank you, I was under the impression that if you do not give igor a coefficient guess, it won't be able to fit? Is there a way to tell it that those are just starting points and not the absolute values? Will it overwrite my values with proper ones? thank you in advance
The values you put into the Coeffs wave will be taken as initial guesses when you provide Coeffs to FuncFit. If they are not changed, then most likely something went wrong with the fit. You can get info about failures or premature end like this:
    Variable V_FitError=0
    Variable V_FitQuitReason=0
    FuncFit ...
    if (V_fitError)
        ... do something to interpret and report error ...
    endif
    if (V_FitQuitReason)
        ... report on termination reason ...
    endif
Read more about this: DisplayHelpTopic "Special Variables for Curve Fitting" DisplayHelpTopic "V_FitError and V_FitQuitReason" John Weeks WaveMetrics, Inc. support@wavemetrics.com