LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How can I stop a while loop when the OK button on a message displayed to the user is pressed?

I am just trying to play a continous tone (inside a while loop) until the OK button on a dialog box is pressed.  I can't get the tone to stop via the OK button.  If the output from OK is wired to the stop in the while loop the loop doesn't execute until OK is pressed.  I think the problem deals with the "OK" field on the message not creating any output until it is pressed, so my while loop is waiting on input from it.
I would appreciate any help!  Thank you.
0 Kudos
Message 1 of 4
(3,222 Views)
This is a threads issue.  Since the dialog is running in the same thread as the sound loop (assumption based off discription of issue) then there can be only a couple of outcomes but the bottom line is that once the dialog becomes active the main loop will wait until the dialog is exited before doing anything else.  Thus you might either get no sound, the dialog, then exit or you get one beep, the dialog, then exit depending on which is run first.
 
You will need to seperate your sound loop from the dialog loop.  I usually do this with queues but whatever works for you.  Below is a snapshot of what you wanted to do using queues... any questions just post back Smiley Happy
Message 2 of 4
(3,188 Views)
You could try adding an event structure to your VI for when the ok button is pressed, if I understand your question correctly.  I attached an example.  Make sure that you create an indicator in the dialog box for the OK button and wire the indicator to the main while loop (the one you want to stop).

Kenny
Kenny

Download All
Message 3 of 4
(3,185 Views)

Thank you both so much!  It works like a champ now. 

 

0 Kudos
Message 4 of 4
(3,164 Views)