name wave in procedure

Hi all, how can I make a wave in a procedure or function with a name that is made of the name of the input wave and a suffix or prefix? I used to use

string xx = nameofwave(inputwave) + suffix
make $xx
wave yy = $xx

yy is the wave reference for the $xx wave, since $xx cannot be used in referencing ( or I am wrong). and I tested, in this way, the output wave will still be named
"xx", not "yy". It doesn't seem to be a good way, however, especially if I have a lot of input waves, and want to add a few suffixes to each (ie make a few waves out of each of the input waves), that means I have to use another set of wave references, like yy, too, which can be quite a few.

Or this could lead to another question. I want to execute the same function over multiple waves, like in
function xx (wave1, wave2, wave3 (,...))
each time, wave1, wave2 remain the same, but wave3 changes, and it will go through a list of waves. From my understanding, wavelist would return all waves in a datafolder, so I cannot put wave1, 2, 3 and others into the same datafolder because I don't want to include wave 1 and 2 in the list for wave3, but if I put the list of waves for wave3 in a subfolder and execute the function in a root folder, it will say wave does not exist.

Is there a good way to solve my problem?

Thank you!!!


I guess your problem is more or less connected to understanding wave referencing and the meaning of internal function reference names vs wave names. Actually, it is a bit difficult to decipher what you want to do and cannot get to work. You can correctly assign waves but still are not satisfied with how things are handled? I try to give some suggestions to the things you mentioned above:

1) internal wave references can be overwritten as often as you like if you want to work with another wave. No need to create a new wave reference for every wave. In for-loops this may look like this:
for (i = 0; i < maxi; i +=1)
string xx = nameofwave(inputwave) + i
make $xx
wave yy = $xx

2) Yes, wavelist will give you a list of the waves in the current folder, but you can filter the names already when calling the function (take a look at the help for wavelist). Also if you happen to know the wave names you want to exclude, you can use stuff like removefromlist to clean up the output afterwards.
3) If you want to work with folders, you need to get into folder references and stuff. There is almost always a way to reference the correct waves in a folder. If you have a practical problem we can try to work through these things. Otherwise you may want to read the help about wave references including folders and, if you are confident, also about data folder referencing.
chozo wrote:
I guess your problem is more or less connected to understanding wave referencing and the meaning of internal function reference names vs wave names. Actually, it is a bit difficult to decipher what you want to do and cannot get to work. You can correctly assign waves but still are not satisfied with how things are handled? I try to give some suggestions to the things you mentioned above:

1) internal wave references can be overwritten as often as you like if you want to work with another wave. No need to create a new wave reference for every wave. In for-loops this may look like this:
for (i = 0; i < maxi; i +=1)
string xx = nameofwave(inputwave) + i
make $xx
wave yy = $xx

2) Yes, wavelist will give you a list of the waves in the current folder, but you can filter the names already when calling the function (take a look at the help for wavelist). Also if you happen to know the wave names you want to exclude, you can use stuff like removefromlist to clean up the output afterwards.
3) If you want to work with folders, you need to get into folder references and stuff. There is almost always a way to reference the correct waves in a folder. If you have a practical problem we can try to work through these things. Otherwise you may want to read the help about wave references including folders and, if you are confident, also about data folder referencing.


Thank you Chozo! I will try as you suggested and then come back! Thank you thank you!!