Problem with the code

Dear all
in the follow procedure there is an error during the execution of the macro

In particular in the line: duplicate /O $freqdomain $destw//creates new wave
which is the 14th line in the procedure. Something is wrong with the duplicate operation.
It is highlighted the "freqdomain".
Does anybody could help me to resolve this problem?
Thank you very much in advanced
Regards,
Giannis
#include <ftmagphase>
Macro AbsorptionMax(name,noise,thickness,index)
    string name
    variable /d noise
    variable /d thickness
    variable /d index
    prompt name "the reference wave name is ?"
    prompt noise "the noise floor level in freq domain = ?"
    prompt thickness "the sample thickness in [m] is = ?"
    prompt index "the THz index of refraction of the sample is ~ ?"
    string freqdomain=name+"_dmag"//creates new wave name
    string destw=name+"_absmax"
    duplicate /O $freqdomain $destw//creates new wave
    //calculates maximum measurable absorption coefficient as described in
    //Jepsen, P. U.; Fischer, B. M. Optical Letters, 30 (1) 29-31 (2005)
    $destw=2*ln(($freqdomain/noise)*4*index/(1+index)^2)/(thickness*100)
    SetScale d 0,0,"", $destw
    display $destw
    Label left "\\Z14\\F'symbol'a\\F'arial'\\Bmax \\M\\Z12 [cm \\S-1\\M\\Z12]";DelayUpdate
    Label bottom "\\u#2\\Z12 Frequency [THz]"
    SetAxis bottom 0,1e+13
    SetAxis left 0,*
    ModifyGraph rgb($destw)=(0,0,0)
Endmacro
I wrapped your code in <igor> </igor> tags.

It looks like your macro accepts in the name parameter the name of an existing wave as a string, and then promptly takes that name and adds "_dmag" to it, and expects that to name an existing wave that can be duplicated as name+"_absmax".

I suspect that the wave name+"_dmag" does not actually exist. It would need to for the Duplicate command to succeed.

--Jim Prouty
Software Engineer, WaveMetrics, Inc.
Dear Jim,

tank you very much for the response but I do not know what to do in order to resolve the problem.
I am not familiar with programing. Is there any more specific advice?
Thank you very much on advanced
Giannis
Jim meant that the macro is expecting a wave which may not be there (i.e., in your experiment or currently selected folder). The problem is that certain expectations are hardcoded into this macro, making it difficult to apply it in general. Are you running the macro from the command line? In this case, look what you enter behind 'AbsorptionMax(' (i.e., the first 'function parameter' in programming terms), most probably a wave name, and image to add '_dmag' to this. If a, probably different, wave with such a name is not present, then the execution fails.

So, the prerequisites to run the macro are not fulfilled in your case, probably due to the programmer having a certain course of action in mind with some other preparation/macro coming before executing this one. A quick and dirty fix would be to delete '+"_dmag"' from the line string freqdomain=name+"_dmag", which would then just use the entered name of the wave. I don't know if that would break the purpose of that particular macro, because I would imagine it was written like that for a reason. Maybe you have to use some other command (from a macro set, I guess?) before.
Dear Chozo,

thank you very much for your advises. I really appreciate it.
I will implement the suggested changes and I will let you know.

Regards,
Gannis