08-24-2012 07:00 AM
Is there any way to store the value of the iteration index of a While Loop when the loop is paused or stopped? I would like to employ this saved iteration index value as an array index for accessing a particular element (or range of elements) in an existing array. When attempting to save the iteration index at the pause event (with both local and global variables or as shift register or tunnel outputs from the While Loop), the “saved” iteration index always resets to zero.
Storing the iteration index will enable the user to process in the While Loop through a user-specified indexed portion of an array. The goal is to add front panel buttons for initial start at index zero (0), start at any index, pause at the current index, resume at the current index, reset to index of 0, stop at a particular index, and global stop. Numeric controls on the front panel would specify the array indexes (start, intermediate pause(s), intermediate resume(s), etc. ) to be looped through.
Thanks for your consideration.
Paul
08-24-2012 07:13 AM
Can you post your vi so that we can see what went wrong ?
08-24-2012 09:04 AM
nijams:
Two of my vis are attached. I cannot find a way to save the iteration index and prevent the saved value from resetting to zero. Also, for an unknown reason the shift register values update even when the While Loop is paused.
Thanks for the help.
Paul
08-24-2012 09:22 AM
It seems you are using "continuous run". That is only a debugging tool, and not a way to do anything useful.
Your loop starts over with each re-run and runs at least once, even if the boolean is false.
All you need is a simple state machine with an idle state and a run state. You never need to leave the while loop.
08-24-2012 09:37 AM
Try something like this rough draft.