I'm a new Igor programmer, and having trouble with the WaveRefIndexed function. I've successfully used the XLLoadWave function to pass in data from Excel, but I can't seem to use the WaveRefIndexed function to properly reference the data as particular waves. When I try to compile, an error message reads, "ambiguous wave point error" and points to the end parenthese on line 3 of the code below:
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.
Quote:
not working:
string specname=WaveRefIndexed(graphname,specnum,1)
Duplicate /O/R=(xl,xr) $specname $remname,$backname
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:
Wave specwave = WaveRefIndexed(graphname,specnum,1)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 $"
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:
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