How to fit in the range chosen by cursors on another graph?

Hello everybody!

Could you, please, advise me the best way to chose the cursors on one graph and then to use their positions for many other graphs to fit?

I'm trying to do it the following way: I call a function to display my reference wave:

function display_aver(CtrlName)  : ButtonControl
    String CtrlName
        string filename = "AvgTrace"
        Display $filename as "Average"
end


Then I would ask the user to set the cursors,
and then I'm trying to do my fitting on loop with pcsr(cursorName [, graphNameStr ])
But it does not work :(

    graphname="Average"
        FuncFit  doubleexpo W_coef   $filename[pcsr(A,graphname),pcsr(B,graphname)]     //fitting


I guess, the way I pass [, graphNameStr ] is wrong. How should I do it?

Thanks in advance!

"Does not work" is a poor description. Error messages can help to find the mistake. A description what should happen and what in fact happens is also very helpful.
My guess is that you confuse the window TITLE with the window NAME. (Activate your displayed window and press CTRL-Y).
display /N=WinAverage $filename as "Average"
graphname="WinAverage "

A couple of other things...
Is "doubleexpo" a user defined function or actually the internal "dblexp_XOffset" function? In the latter case, CurveFit might be a better option to do the fit -- but I don't know your experiment.
If you want to fit a lot of waves, it might be better to store the cursor position in two variables and use these in the fitting part (e.g., Low & High).
"$filename" in your example should be replaced by
wave data=$filename
CurveFit dblexp_XOffset, data[low,high]

Substrings also use the str[low,high] syntax and I once experienced some trouble with "$string[]" constructs...

HJ

Thank you very much!
The problem really was that Display as did not change the name of the graph.