get the name of the wave on the top graph

How to get the name of the wave on the top graph and use it in WaveStats ?

What this simple method does not work in my function :

myWave = WaveName("",0,1)
WaveStats/R= [pcsr(A), pcsr(B)] myWave


Each time I really tried to start programming in Igor then I give up.



Thank you
The WaveName function returns a string containing the wave's name. WaveStats needs a wave reference, which means that you need a $ operator to turn the contents of the string into a wave reference:
String wname = WaveName("", 0, 1)
WaveStats/R=[pcsr(A), pcsr(B)] $wname

But this could fail if the wave is in some data folder other than the current data folder. That's because WaveName returns just the name of the wave, not the full data folder path to the wave. The more modern and reliable method is like this:
Function test()

    Wave w = WaveRefIndexed("", 0, 1)
    WaveStats/R=[pcsr(A), pcsr(B)] w
end

You can combine that into a single line:
WaveStats/R=[pcsr(A), pcsr(B)] WaveRefIndexed("", 0, 1)
and that line doesn't have to be in a user-defined function.

John Weeks
WaveMetrics, Inc.
support@wavemetrics.com
Thank you , it works. I took the first solution. I think I would come back here more often if I continue programming;-)