LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

get comments while collecting data

Solved!
Go to solution

I have a program that collects data in the lab and displays it on screen as it goes.  I want to add a commentary capability, so that if the user sees something interesting she can click "Comment", and add a comment which will be saved in a text file at the end of the data acquisition session.  I'd like to "time stamp" the comment using the time elapsed (since start of acquistion) when "Comment" button is pressed.  So I wrote a chunk of test code (attached), which does not work as desired.  When code starts, it waits for user to start a timer (the data acquisition would start at this point, in the full blown program).  Then the timer runs and the program waits for user to click "Stop" , and then displays the elapsed time between start and stop.  At least it's supposed to work that way.  While it's waiting for the Stop, it monitors the "Comment" button, and gets user input if Comment button is pressed.  It adds the current elapsed time to the user comment, as desired.  Trouble is, the program just pays attention to the Comment button and doesn't pay attention to the Stop button. So program doesn't stop when user hits Stop.  I want to allow for zero, one, or more user comments during the time between "Start" and "Stop". What to do?  Thank you.

 

0 Kudos
Message 1 of 6
(2,604 Views)
Solution
Accepted by topic author WCR

Try running this with execution highlighting (the "light bulb" icon in the toolbar) and you'll see what's happening.  Your code is, in fact, paying attention to the stop button - just not when you want it to.  If you click "Stop" and then click the "Comment" button, you'll find that your code stops as expected.  The problem is that your inner while loop (checking the "Comment" button) runs continuously, and the code never checks the condition of the outer while loop (the one connected to the "Stop" button) until the inner while loop completes.

 

A better solution would be to eliminate all the sequence structures and nested while loops, and replace it with a single while loop.  Inside that while loop you could check for the Stop button to terminate the loop, and put the code to handle the Comment function inside a case structure wired to your Comment button.

Message 2 of 6
(2,592 Views)
Try this code out.  It uses an event structure to monitor the button presses.  It is a good way for you to solve this problem. 
Message 3 of 6
(2,585 Views)
Thank you very much. Could you repost that in LV 8.5 so I can open it?  T
0 Kudos
Message 4 of 6
(2,537 Views)
Message 5 of 6
(2,533 Views)
I never would have figured out how to do that as efficiently.  Your code works very nicely!  Thank you!
0 Kudos
Message 6 of 6
(2,517 Views)