Transfer of text items between text waves

I have data from several analytical measurements combined with a corresponding sample code in a text wave. After performing calculations to track analytical errors I wish to create a new text wave containing only the sample codes of the wrong samples.

In a first attempt I simply wrote, as is usual for numbers:

samplecode1[k]=samplecode2[m]

This does not work. Then I tried to write a sample code to a string and to read it into a new text wave:

string_test=samplecode1[1]
samplecode2[0]=string_test

This works perfectly in the Command window but not in a program. Sofar, I did not find any hint how to achieve this simple operation.

Thanks for your input!

Hans

Are you receiving any error messages? Or can you explain what you mean by not working? My first thought was that you left off a "/t" to designate a text wave but this will cause and error.

The following test code works for me in both v6.38 and v7.05 on Win7.

function ftest()
    make/t/o wtext = "test"
    make/t/o wtext2 = "test2"
   
    variable k = 0
    variable m = 1
   
    wtext2[k] = wtext[m]
   
    print wtext2[k]
end


The printed output is "test."

Can you post a similar, simple function that shows the problem?
Thank you very much for your suggestion that I left out a "/T" somewhere. I did not receive any error, but nothing was added in the 2nd textwave. Your procedure performed well on my Mac.

The failure appreared simply to be due to the fact that in the wave declaration at the start of the function I declared the sample code wave as "Wave" and not as "Wave/T". The other text wave is made in the program and correctly defined

Changing the initial declaration solved the problem! Thanks again for your kind help! (As I am not really new to IGOR I feel a bit ashamed...)

Hans