Waves from indexed tables
aboris
XLLoadWave/R=(A2,Z400)/O/I/T/W=1/C=2 "Choose Columns Containing Abundance Values"
String AbundTable = WinName(0,2,1)
String AbundWave1str = WaveRefIndexed("AbundTable",0,1)
Wave AbundWave1 = $AbundWave1str
String AbundTable = WinName(0,2,1)
String AbundWave1str = WaveRefIndexed("AbundTable",0,1)
Wave AbundWave1 = $AbundWave1str
Am I using the WaveRefIndexed function incorrectly, or is it possible that there is a bug in the wave referencing here? I'm using version 6.22A.
It should be this:
The first specifies a table literally named AbundTable. The second specifies a table whose name is stored in the string variable AbundTable.
September 22, 2012 at 06:23 am - Permalink
working:
string specname=Wavename(graphname,specnum,1)
Duplicate /O/R=(xl,xr) $specname $remname,$backname
not working:
string specname=WaveRefIndexed(graphname,specnum,1)
Duplicate /O/R=(xl,xr) $specname $remname,$backname
This gives a "ambiguous wave point error".
But instead this is working again:
Duplicate /O/R=(xl,xr) WaveRefIndexed(graphname,specnum,1) $remname,$backname
But I need WaveRefIndexed(graphname,specnum,1) as a variable.
Any suggestions?
March 13, 2013 at 08:05 am - Permalink
Here you are getting the wave name as a string from the WaveName function. Then you use the $ operator inline to generate a wave reference.
In this case, the WaveRefIndexed function returns a wave reference, not a string. So it is ready for your use as a wave without using the $ operator. You can make a wave reference variable like this:
Duplicate /O/R=(xl,xr) specwave $remname,$backname
... further uses of specwave as a wave ...
Making a wave reference gives you a variable that can be used just as you would use an actual wave name in a command like Duplicate. It is a stand-in for a wave that is unknown at compile time.
This whole business with $ operator, strings and references can be quite confusing. It took me a while to figure out exactly when I need one or another solution. It can be tricky sometimes to understand from our documentation whether you need (or receive) a string or a reference. But in general, if we document that something returns a "wave name" it is returning a string, and if we document that it returns a "wave reference" then what you get is not a string. In fact, the documentation for WaveName says "returns a string containing the name".
You might want to review some topics in our help files:
DisplayHelpTopic "Accessing Waves In Functions"
DisplayHelpTopic "Converting a String into a Reference Using $"
John Weeks
WaveMetrics, Inc.
support@wavemetrics.com
March 13, 2013 at 09:28 am - Permalink