06-18-2012 06:16 PM
I have a question about passing a counter variable between different event/while loops and having the value increment regardless of which loop is initiated.
The basic problem is that I am writing unique filenames to for data collected on a spectrometer, and I would like the value at the end of the file name to increment each time I collect the data. There are several different ways I have can collect the data, and I would like the counter to increment when any of the collections is triggered. The attached file shows basically what I am trying to accomplish. The collect buttons represent two different types of data I collect from my instrument, but the counter variable isn't passed correctly between the two loops. Is there any way I can get the counter to increment so that both loops see the same counter value?
Thanks for your help.
Solved! Go to Solution.
06-18-2012 07:15 PM
You should use action engine. See attached. While trying to change your code as little as possible. I did the following:
1. Created CNT.vi action engine.
2. Fix the sticking key problem that you were having (one button press register multiple events) by changing the event to mouse down. I don't know the problem happens, but it does for your program.
3. Add a time out case for both event structure. With your design, you can't stop the loops properly without the timeout cases. You will have stuck without the event structures. Unless you have a really good reason to use two event structure, try to stick with one.
06-18-2012 07:41 PM
06-19-2012 03:07 PM
After a moment of reflection I realized you were completely right. This has made my actual code much cleaner (the code I posted was only an example of the problem I was working on). THanks!