Unexpected Wave Error: Using WaveStats in a Procedure Function

Hello:

I need help because I have a series of datafiles with a basename ("mws_2-125_00", "mws_2-125_10", "mws_2-125_20"...) that increment (but a zero is placed at the end). My real issue is trying to find the maxima and its index of each datafile all at once and store those the maxima and index in a matrix.

I have written a function, but I keep getting an error I do not understand "Wavestats error: unexpected wavename". The compiler says my function is OK, but when I execute I get the error.

function Peaks(basename)
    string basename
    Make/O/N=(119,2)/D results
    string swave
    variable j
    for(j=0;j<120;j+=119)
        swave = "basename"+num2str(j)+"0"
        wave temp = $swave
        wavestats temp
        results[j] [0] = V_max  // maximum in column 1
        results[j] [1] = V_maxloc      // indexed value in column 2
    endfor
end


Please help. Any other method to process a series of a hundred or more datafiles at a time to find and store the maxima and index would be appreciated. I am new to Igor and this has been very time consuming/frustrating.

Thank you so much in advance.
I think the problem lies in the use of a dash in your wave name. Either change the dash to some other character (say, an underscore) or surround the name with single quotes when you assign the value to swave. This should help... give it a try. I usually avoid non-standard names, so I'm rusty in this area.
There are a few symbols which can be used in wave names, which don't seem to be supported in certain functions. As a result, I tend to focus on wavenames which only utilize underscore to separate letters/numbers and waves which start with a letter.

Waves which start with a number will have to be surrounded with single quotes most times, but certain functions will reject the name with the single quotes so it can be tricky.

There may be other problems but this statement:
swave = "basename"+num2str(j)+"0"


should be this:

swave = basename+num2str(j)+"0"


I figured this out using the debugger:
DisplayHelpTopic "The Debugger"


The function will work with liberal names (e.g., containing a dash) because this statement works with liberal names without quoting:
wave temp = $swave


To learn about liberal names, execute:
DisplayHelpTopic "Liberal Names"
DisplayHelpTopic "Accessing Global Variables and Waves Using Liberal Names"


Thank you all so much for your responses. I really appreciate as a new user being able to come here and get feedback (or else I would have given up!)

Indeed, the problem was the non-standard names. It also took me a really long time to do this, but I was able to rename all my files into simpler names, and the function I wrote then worked right away.

.....I don't know if I want to scream because I am happy it works or because it took so long and yet was so simple!!!