Create a folder using a variable name

Hello everyone,

Beginner here, I used Igor for a little while now but only using user-built macro (not by me), and I would like to start doing things by myself.

I have a lot of waves, and for each of them I need to copy them and make various operations on the different copies. This seems a easy enough task to begin with.
My issue is that I would like to create a new folder for each of those waves, names after the wave, in which all the copies would be stored. 

Basically, if I have "wave1" in root, I want my function to make a subfolder called "wave1", and then copy "wave1" in it.

The issue in the following example of what I tried the new folder created is literally called WaveName, and not the name of the wave I put in the function when running it.

Any advice ? I feel I am still a bit confused by what is recognized as what in Igor.

function PrepWave(WaveName)

String WaveName
Wave W=$WaveName
NewDataFolder/o/s WaveName
Duplicate/o W, root:WaveName:W_1

End

NewDataFolder expects a name.

Your WaveName parameter is a string. Use $ to convert the contents of string into a name.

For details, execute:

DisplayHelpTopic "String Substitution Using $"

Also, I recommend that you change the name of your parameter from "WaveName" to something else, such as "Name", because WaveName is the name of a built-in function which can cause confusion.

You have a similar issue with your Duplicate statement. You can fix it using $.

 

In reply to by hrodstein

Thank you, it worked.

I had already tried using $, but a error was returned, I assume it was because of the use of "WaveName".
Here is the MWE I have now.

function PrepWave(WaveInit)
String WaveInit
Wave W=$WaveInit
NewDataFolder/o/s $WaveInit

Duplicate/o root:$WaveInit $WaveInit
End