Time Specific Code Pausing with a Panel
hi,
Is it possible to pause code execution for a specific amount of time while still being able to using buttons in a control panel but continue the code execution at the end of the wait if a "stop" button is not clicked?
I have a procedure which has a control panel with buttons and a sub window graph. I'm trying to have the option of updating the graph manually (with button clicks in a pauseforuser) or automated in a loop. Ideally, this loop will wait for a specific time (~1 second) but still be able to use the buttons (and procs of those buttons) while waiting. At the end of the wait, it will update the graph. There would be a special button that would stop this loop and go back to manual mode.
While I have the manual portion working, the automated loop won't let me click the buttons. Currently I'm using a delay function (ticks) then updating the graph (panel stays open without closing). I'm not sure if it is a problem with delaying in a function preventing user input or if my panel is not set up properly to click buttons without a pauseforuser (I think pauseforuser requires closing the window to continue code which i would prefer not to rebuild the panel each loop iteration).
thanks,
Yes, a delay or pause for user does not work since the function where this is called is not able to finish, so all interaction with other functions such as button procedures is blocked. I am not completely sure what you are trying to do, but it sounds to me like a background task would be the right choice here. A background task is a function which periodically runs in the background in variable intervals. In the automated mode such a background task could be started which counts the time until an update is initiated. If you want to periodically update the graph anyway, then you do not even need to count the time, and just set the background task interval to your desired interval. You can use the rest of Igor just fine.If you want to know more, execute the following in the command window:
DisplayHelpTopic "Background Tasks"
April 4, 2020 at 03:30 am - Permalink
It sounds to me that the suggestion from chozo is what you need. It also sounds to me as though you want to do this:
* give the user a notice to start modifications for a specified time
* fire off a background task to run a count-down clock for that specified time
* when the background task finishes, put up a "end of time" warning and lock down/disable the input buttons
April 4, 2020 at 06:40 am - Permalink