Pseudo "STOP" button control
s.r.chinn
// This snippet demonstrates an example to stop an executing procedure from a
// pseudo-"STOP" button in a control panel
// To begin, first execute the Panel0() recreation macro from the command line.
function Monitor()
variable i=0, vLoop = 1
Do
ModifyControl button1 disable = 0 // show the "STOP" button
ControlUpdate /W=Panel0 button1
// your loop step goes here; this test is a simple count display and increment
ValDisplay valdisp0 value=_NUM:i
ControlUpdate /W=Panel0 valdisp0
i+=1
Sleep/S 0.25
// end of your loop step
GetMouse /W=Panel0 // test for mouse press in pseudo-"STOP" button area
if( (V_flag==1)&(V_left>125)&(V_left<175)&(V_top>110)&(V_top<130) )
VLoop = 0 // condition to quit the Do-While loop
ModifyControl button1 disable = 1 // hide the "STOP" button
endif
While(vLoop)
end
//-----------------------------------------------------------------------------
Function ButtonProcStart(ctrlName) : ButtonControl
String ctrlName
Monitor()
End
//-----------------------------------------------------------------------------
Window Panel0() : Panel
PauseUpdate; Silent 1 // building window...
NewPanel /W=(708,73,1008,273)
ValDisplay valdisp0,pos={95,71},size={100,14},title=" count"
ValDisplay valdisp0,limits={0,0,0},barmisc={0,1000},value= _NUM:0
Button button0,pos={125,28},size={50,20},proc=ButtonProcStart,title="START"
Button button1,pos={125,110},size={50,20},title="STOP", disable = 1
EndMacro
// pseudo-"STOP" button in a control panel
// To begin, first execute the Panel0() recreation macro from the command line.
function Monitor()
variable i=0, vLoop = 1
Do
ModifyControl button1 disable = 0 // show the "STOP" button
ControlUpdate /W=Panel0 button1
// your loop step goes here; this test is a simple count display and increment
ValDisplay valdisp0 value=_NUM:i
ControlUpdate /W=Panel0 valdisp0
i+=1
Sleep/S 0.25
// end of your loop step
GetMouse /W=Panel0 // test for mouse press in pseudo-"STOP" button area
if( (V_flag==1)&(V_left>125)&(V_left<175)&(V_top>110)&(V_top<130) )
VLoop = 0 // condition to quit the Do-While loop
ModifyControl button1 disable = 1 // hide the "STOP" button
endif
While(vLoop)
end
//-----------------------------------------------------------------------------
Function ButtonProcStart(ctrlName) : ButtonControl
String ctrlName
Monitor()
End
//-----------------------------------------------------------------------------
Window Panel0() : Panel
PauseUpdate; Silent 1 // building window...
NewPanel /W=(708,73,1008,273)
ValDisplay valdisp0,pos={95,71},size={100,14},title=" count"
ValDisplay valdisp0,limits={0,0,0},barmisc={0,1000},value= _NUM:0
Button button0,pos={125,28},size={50,20},proc=ButtonProcStart,title="START"
Button button1,pos={125,110},size={50,20},title="STOP", disable = 1
EndMacro
Forum
Support
Gallery
Igor Pro 9
Learn More
Igor XOP Toolkit
Learn More
Igor NIDAQ Tools MX
Learn More