LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Turning a VI with a while loop into a SUB vi

My question is can vi's that use while loops be turned into sub vi's and used in the main while loop of a main program. So I have these vi's that work just great. They have their own while loops. Should I leave them like that, or can get rid of their while loops and put the code into my own main loop? There by using only one main while loop. 

0 Kudos
Message 1 of 7
(3,499 Views)

Yes but keep in mind they will iterating at the same rate so if one loop runs slow the rest will slow down to the iteration rate of the slowest.

 

Ben

Retired Senior Automation Systems Architect with Data Science Automation LabVIEW Champion Knight of NI and Prepper LinkedIn Profile YouTube Channel
0 Kudos
Message 2 of 7
(3,498 Views)

Your question is way too vague to give an answer. There are many reasons for while loops and only some can be eliminated by using the while loop of the caller instead. If these are toplevel loops that just poll/repeat, you are fine. If these are tight, self terminating while loops of an iterative procedure (e.g. newton-raphson), they need to stay. Same if they need to spin independently at different rates.

 

If you are a relatively new programmer, feel free to show us your code drafts. Most likely we will be able to give much more specific and useful advice.

0 Kudos
Message 3 of 7
(3,494 Views)

Yes, I am new. I recently completed core1 and core2. So trying to put it all together intelligently. Ok I will put something together and post the code. Unfortunately,  there is another Labview programmer here that is not much help to me. I think he see's my efforts to be a good Labview programmer a threat. Its too bad he acts that way. I'm only trying to help. But I have the NI forums; Thank Goodness. Ok, I will  post code.

 

Regards,

LeatherNeck1957

Message 4 of 7
(3,481 Views)

@Leatherneck1957 wrote:

Yes, I am new. I recently completed core1 and core2. So trying to put it all together intelligently. Ok I will put something together and post the code. Unfortunately,  there is another Labview programmer here that is not much help to me. I think he see's my efforts to be a good Labview programmer a threat. Its too bad he acts that way. I'm only trying to help. But I have the NI forums; Thank Goodness. Ok, I will  post code.

 

Regards,

LeatherNeck1957


Maybe he's Navy...?

Bill
CLD
(Mid-Level minion.)
My support system ensures that I don't look totally incompetent.
Proud to say that I've progressed beyond knowing just enough to be dangerous. I now know enough to know that I have no clue about anything at all.
Humble author of the CLAD Nugget.
0 Kudos
Message 5 of 7
(3,451 Views)

@billko wrote:

@Leatherneck1957

... 

Regards,

LeatherNeck1957


Maybe he's Navy...?


This is of  far off-topic that it goes into a spoiler!

 

Spoiler

 

A sailor and a marine are drinking in a bar after both completing boot camp. They sneer at each other and match each other beer for beer. Eventually the have to respond to nature and visit the Men's room. After finishing their business they both go to the sink. The marine washes his hands and the sailor proceeds to comb his hair.

 

Marine : "In boot camp they taught us to wash our hands after using the facilities."

Sailor :

 

Spoiler
"In boot camp they taught us not to piss on our hands"

 

 

 That joke of course can be told either way.

 

 

 

Ben

Swabbie1958

Retired Senior Automation Systems Architect with Data Science Automation LabVIEW Champion Knight of NI and Prepper LinkedIn Profile YouTube Channel
Message 6 of 7
(3,438 Views)

Hoorah Swabbie1958

0 Kudos
Message 7 of 7
(3,402 Views)