Return a text wave reference?

It's very useful to return strings with function /T stringFunction() and to return waves with function /WAVE waveFunc(), but is it impossible to combine these?

Preliminary googling suggests not, but I'd like to make sure.
If the Function/S (/T is deprecated but still works) was returning the path to the wave or just the wave name, you can get those out of a wave reference returned by Function/WAVE using GetWavesDataFolder or NameOfWave.

Otherwise you can return the string as a "pass-by-reference" parameter:
Function/WAVE myFunction(str)
    String &str // output

    str="hi!"
    Make/O data=p
    return data
End

--Jim Prouty
Software Engineer, WaveMetrics, Inc.
That's a nice feature which I wasn't aware of! It has always bugged me that waves are the only thing passed by reference. (For others: Pass-by-Reference is a topic in the Manual, page IV-45 for manual version 6.3)

But this actually won't work in my case. I want to do something like:

Function /WAVE/T get_textw_reference(year) // Doesn't work!

    variable year // 2012, 2013, 2014, ...
    wave/T textw = root:$year:textw
    return textw

end


Because textw is not of fixed length, I need to do this dynamically.
The syntax is
Function/Wave GetRef()

    Make/T wv
    return wv
End

as you must not specify which wave type you return. So Function/Wave allows to return a wave of arbitrary type.
Function test()

    Variable year = 2014
    String yearstr=num2str(year)
    Wave/T tw = root:$(yearstr):textw

    print numpnts(tw)
end

The parens around yearstr are required because a string expression could be referencing a something in a path. The $ operator takes a string, not a number, so your $year won't work.

John Weeks
WaveMetrics, Inc.
support@wavemetrics.com