From 04:00 PM CDT – 08:00 PM CDT (09:00 PM UTC – 01:00 AM UTC) Tuesday, April 16, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

What's the best way to give a user the option of stopping a vi or rerunning it? I wrote something that works but I imagine it's not the best way to do it.

Solved!
Go to solution

I have a VI that runs a stepper motor then stops. I wanted the operator to have the option of rerunning the VI or stopping it completely. To do this I added a while loop around the entire VI.I have an example VI showing how I accomplished this, but I'm sure there's a more efficient approach. Any suggestions?

 

Thank you.

0 Kudos
Message 1 of 4
(2,228 Views)
Solution
Accepted by topic author chuck72352

There is almost never a good reason to use the Stop Sign Abort Execution function.

 

Your while loop is fine.  What you really want to do is make a state machine that has at least 2 states. 1.  Running the test.  2. Idle, waiting for the user to hit a run button again, or hitting an End program button.

Message 2 of 4
(2,224 Views)

I didnt think of that because there's only one state in the program, but your idea is easy to implement.

 

Just curious, in my application what are the hazards of the "Stop Sign Abort Execution"?

 

Thanks!

0 Kudos
Message 3 of 4
(2,220 Views)

It's like hitting the abort button on the toolbar at the top of LabVIEW.  It means you are basically killing the program wherever it is and not doing the things you need to do to end the program gracefully such as closing DAQ tasks, closing files, closing open references. .....

Message 4 of 4
(2,209 Views)