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.
PopupMenu popup0, value=WaveList("*", ";", "")
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.
For ReplaceWave you can use a string variable for the name of the wave to be replaced:
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
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.
Thank you for the example. It gave me the hint that I was looking for.
Back to top