LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Execute a For Loop in a While Loop Only Once

I have a for loop inside a while loop in a VI.  The while loop is there so the user can select some Boolean options on the front panel and navigate to some file directories.  Then once everything is setup, the user hits a button, which executes a for loop and "post processes" the tdms files in the directory the user selected.  My problem is, once the for loop is finished, it just starts over again and starts processing the files over again. 

 

I want the the entire while and VI to stop, once the for loop is finished. How do I do that?

 

Thanks!

Adam

0 Kudos
Message 1 of 23
(1,872 Views)

Add an OR node before the conditional terminal to capture the Boolean value from the Stop button and a True value from the For Loop.

-------------------------------------------------------
Control Lead | Intelline Inc
0 Kudos
Message 2 of 23
(1,850 Views)

Move the for loop out of the while loop so that when "the user hits a button" the while loop stops, and you move on to running whatever is in the for loop (may not even need the for loop if it's only executing once), once that stuff executes the VI is complete. 

0 Kudos
Message 3 of 23
(1,808 Views)

Another (better?) option is to create a simple state machine.

---------------------------------------------
Certified LabVIEW Developer (CLD)
There are two ways to tell somebody thanks: Kudos and Marked Solutions
0 Kudos
Message 4 of 23
(1,795 Views)

Can you elaborate on how to create a simple state machine?

0 Kudos
Message 5 of 23
(1,789 Views)

WolfmansBrother - thanks for uploading an example VI.  I only have LabView 2019, so can you upload a 2019 version for me?

 

Thanks!

0 Kudos
Message 6 of 23
(1,782 Views)

let me google that for you...

 

https://labviewwiki.org/wiki/State_Machine

---------------------------------------------
Certified LabVIEW Developer (CLD)
There are two ways to tell somebody thanks: Kudos and Marked Solutions
0 Kudos
Message 7 of 23
(1,775 Views)

Resources to look at would be

 

- NI Simple State Machine Template

 

or google "labview state machine"

 

CLA, CTA
0 Kudos
Message 8 of 23
(1,771 Views)
0 Kudos
Message 9 of 23
(1,769 Views)

Yep, I guess I could have googled that.  🙂

0 Kudos
Message 10 of 23
(1,748 Views)