converting a wave reference into a textwave

I am using the code below to fill a wave with text from a textwave. This type of code works fine for numeric waves, but it does not work with text waves. What am I doing wrong, why w12 does not behave as a textwave?

Many thanks for your input!

Hans

wave/T monstercode, modelT, M_IB_hoog_EC_OK_range

string suffix

string name12=nameOfWave(M_IB_hoog_EC_OK_range); Duplicate/O modelT, $(name12+suffix)/wave=w12 
w12[k2]=monstercode[i]
Screen Shot 2018-02-16 at 13.59.04.jpg
Try adding the /T flag in your Duplicate operation to let Igor know the new wave will be a text wave. See "Type Flags" in the command help for Duplicate for details.
Do you need to say Duplicate/O/T? Also, unless you declare it somehow, suffix is a null string. The end result that should work is

wave/T monstercode, modelT, M_IB_hoog_EC_OK_range
string suffix, name12
suffix = "_modified"
name12=nameOfWave(M_IB_hoog_EC_OK_range) + suffix
Duplicate/O/T modelT, $(name12)/wave=w12   
w12[k2]=monstercode[i]


--
J. J. Weimer
Chemistry / Chemical & Materials Engineering, UAH
In addition to what others have said, I can offer the following example lines you can execute on the command window:

make/o/t/n=3 w_text0 = {"a", "b", "c"}
string s_suffix = "_end"
string s_text1 = nameofwave(w_text0) + s_suffix
print w_text0
//prints:  w_text0[0]= {"a","b","c"}
duplicate/o/t w_text0, $s_text1 //creates w_text0_end
print w_text0_end
//prints:  w_text0_end[0]= {"a","b","c"}


best,
_sk
Thank you all for your kind help. Adding the /T flag in the Duplicate operation works perfectly indeed!

Thanks,

Hans