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=preturn data
End
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.
Function test()Variable year = 2014String yearstr=num2str(year)Wave/T tw = root:$(yearstr):textw
printnumpnts(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.
Otherwise you can return the string as a "pass-by-reference" parameter:
--Jim Prouty
Software Engineer, WaveMetrics, Inc.
January 22, 2014 at 10:48 am - Permalink
But this actually won't work in my case. I want to do something like:
Because textw is not of fixed length, I need to do this dynamically.
January 23, 2014 at 02:00 am - Permalink
as you must not specify which wave type you return. So Function/Wave allows to return a wave of arbitrary type.
January 23, 2014 at 03:48 am - Permalink
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
January 23, 2014 at 05:17 pm - Permalink