
How to use SliderValue of a SliderControl inside a function

supra
The function MoveSegment shift( along y) the part of the graph between two cursor. Can anybody give me some idea.
The example in Igor helpfiles are mainly based on structure based code...so didnt help me lot
NVAR SliderValue= root:SliderValue Slider slider1,pos={700,50},size={50,200},proc=MySliderProc Slider slider1,limits={-500,500,10},value= 0, vert= 1 //--------------------------- Function MySliderProc(ctrl, SliderValue, event) : SliderControl String ctrl // Slider $cntl Variable event // bit field: bit 0: value set, 1: mouse down, 2: mouse up, 3: mouse moved if (event %& 0x1) // bit 0, value set MoveSegment() endif return 0 End //--------------------------------------------- Function MoveSegment() NVAR SliderValue= root:SliderValue WAVE/Z yWave = CsrWaveRef(A) if (!WaveExists(yWave)) // Cursor is not on any wave return -1 endif WAVE/Z xWave = CsrXWaveRef(A) if (!WaveExists(xWave)) // Cursor is not on XY pair return -1 endif Variable startX = hcsr(A) Variable endX = hcsr(B) if (startX > endX) return -1 endif YWave = (XWave>=startX && XWave<=endX) ? YWave + SliderValue : YWave return 0 End
NOTE: I haven't run this- there may still be problems.
It really isn't hard to use the structure-based version of the action procedure, and they are faster and future developments will go into the structure-based procedures. Like this:
John Weeks
WaveMetrics, Inc.
support@wavemetrics.com
June 7, 2012 at 05:09 pm - Permalink
in the current code of MoveSegment function when I move the silder the y wave changes..but it changes the y wave in every slider move ..I cant bring it back to its initial value of y ...
how can I do that...such that ..say if I change slider by 10 ..y wave will be y+10 ...and then next time if I change the slider by 50 it should be y+50 ...now in current sitaution it becomes cumulative like this two slider change makes y+10+50 and eventually its completley out of control ( as I apply it to graph...the motivation is to shift the graph along y by certain value)
June 7, 2012 at 06:13 pm - Permalink
I would recommend making a copy of yWave. say,
Then, your function could do ywave = ycopy + slidervalue.
This way, ywave on the graph will always move in reference to it's original values.
June 8, 2012 at 06:25 am - Permalink
Thank you so much for your reply. As you said I tried to duplicate Ywave in Ycopy..
but still it does not work. Can you think of any other way to do it ?
June 8, 2012 at 08:38 pm - Permalink
But you don't need to copy the entire wave. All you need to store is what you previously added to the wave. Here is code that does that:
June 9, 2012 at 10:31 am - Permalink
June 9, 2012 at 04:09 pm - Permalink