Update traces using a popup menu

Hi,

Does anyone have a procedure to update the Y wave in a graph using a popup menu (subwindow)? I have tried using ReplaceWave in the procedure of the popupMenu control, but that doesn't work more than one time, as the current wave would be different from the original wave when I try to change it a second time.

Any suggestion will be appreciated.
I don't fully understand the question, especially "the current wave would be different from the original wave when I try to change it a second time". I'm not sure if you mean the current wave in the graph or in the popup menu.

However attached is an experiment that might give you some ideas.

This statement:
PopupMenu popup0, value=WaveList("*", ";", "")

causes Igor to reevaluate the value each time the popup is clicked.

Depending on how you are doing things, you may need to use ControlUpdate to force Igor to reevaluate.

If this does not solve the problem then perhaps you can describe it in more detail or post a mockup so we can see what you are doing and what you are up against.
ReplaceWave.pxp
temasi wrote:
I have tried using ReplaceWave in the procedure of the popupMenu control, but that doesn't work more than one time, as the current wave would be different from the original wave when I try to change it a second time.


For ReplaceWave you can use a string variable for the name of the wave to be replaced:

trace= $wName

So wName can be set to the name of the currently displayed wave. The problem then becomes how to determine that wave name. You can keep track of it in a global string variable or maybe in the window note (see SetWindow operation); you could also use the WaveList function to return a list of waves in the current directory that displayed in a given window .
Perhaps the problem is that you want to use ReplaceWave to change the wave displayed by a given trace, but after you do that the trace name changes. I can think of two approaches to the problem:

1) Use TraceNameList function to get a list of the trace names in your graph. Then use ReplaceWave on whatever trace is listed at a given index in the list (note that this is psuedocode, not working code):

String tlist = TraceNameList(...)
String tname = StringFromList(1, tlist)   // to act on the second trace in the graph
ReplaceWave trace=$tname


2) If you can require the use of the latest version of Igor, use the new feature that allows you to give a specific name to a trace. That is done using /TN wit the Display or AppendToGraph commands:

AppendToGraph mywave/TN=myTrace vs myXwave

Now you can always reference that particular trace using an unchanging trace name.

John Weeks
WaveMetrics, Inc.
support@wavemetrics.com