Feedback to the waves whose name expressed with $

I am trying to update waves whose name consist a combinations of string.
but I cannot solve the error... please help

string a = base
variable b = 3
variable data = 2
string wavename = base + num2str(b)

wave w0 = $wavename
w0[data] = 3
$wavename = w0
Hi,

I can see why this doesn't work, but like your last question, I can't see what you are trying to do. I'm guessing you probably want to do this in a loop?

I think you need to do the Tour and work through Getting Started with Igor Programming. It will be worth it.
I am trying to update specific wave whose name was declared with variable controlled by GUI.
I tried to find out in igor programming.pdf, but I could not find answer for that...


sjr51 wrote:
Hi,

I can see why this doesn't work, but like your last question, I can't see what you are trying to do. I'm guessing you probably want to do this in a loop?

I think you need to do the Tour and work through Getting Started with Igor Programming. It will be worth it.


First, "wavename" is the name of an Igor built-in function, as you can see by the red syntax coloring. We probably shouldn't let you do that :)

Otherwise, everything but the last line seems fine as long as "base" is defined in some way. But the last line is not a proper use of the $ operator if it is in a function. My guess is that the error you refer to was "Can't use $ in this way in a function". It is not very useful in general, to report that "an error occurred". It is much more useful to those trying to help you if you tell us what the error message was.

What were you trying to achieve with that line?

John Weeks
WaveMetrics, Inc.
support@wavemetrics.com
Thanks for kind explanation.
Since it is the first time to make program with Igor, I am suffering many problems even asking something :)

The problem that i suffer from is what you mentioned. "Cant use $ in this way in a function"

There are some waves whose names are "allignepoint_n", whose n is variable such as 1, 2, 3, 4... etc
I am trying to control the variable n using "popupmenu". I can get some number but I cannot call the wave again using the variable.
The final goal is to update those waves such as "allignpoint_1", "allignpoint_2" after some calculation.

Thank you for kind help in advance.

johnweeks wrote:
First, "wavename" is the name of an Igor built-in function, as you can see by the red syntax coloring. We probably shouldn't let you do that :)

Otherwise, everything but the last line seems fine as long as "base" is defined in some way. But the last line is not a proper use of the $ operator if it is in a function. My guess is that the error you refer to was "Can't use $ in this way in a function". It is not very useful in general, to report that "an error occurred". It is much more useful to those trying to help you if you tell us what the error message was.

What were you trying to achieve with that line?

John Weeks
WaveMetrics, Inc.
support@wavemetrics.com
Here's how you would refer to the waves you described:
Variable counter = 1 // replace this with a way to select your wave number or loop though the numbers
String currentName = "allignpoint_" + num2istr(counter)
Wave workwave = $currentName // you do not need to change anything here in a loop etc. changing the 'counter' will replace the wave definition

Now you could do operations just by calling 'workwave':
Variable data = 2 // replace this with a way to select your data position
workwave[data] = 3