Return a text wave reference?
jcor
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.
Otherwise you can return the string as a "pass-by-reference" parameter:
String &str // output
str="hi!"
Make/O data=p
return data
End
--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:
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.
January 23, 2014 at 02:00 am - Permalink
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.
January 23, 2014 at 03:48 am - Permalink
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
January 23, 2014 at 05:17 pm - Permalink