From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, 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: 

difference between using while loop & run continously

hai,
   i like to know the difference between using while loop &  using run continuously ,  because i saw many aplication where they are using while loop just for closing the total execution.....
 
 
 
thanks in advance
0 Kudos
Message 1 of 4
(2,376 Views)
In general you can say you should never use 'run continiously' it is just a debugging feature. Your end users should never use the run (or run continiously) button.
A stop button is much better

Ton
Free Code Capture Tool! Version 2.1.3 with comments, web-upload, back-save and snippets!
Nederlandse LabVIEW user groep www.lvug.nl
My LabVIEW Ideas

LabVIEW, programming like it should be!
0 Kudos
Message 2 of 4
(2,364 Views)
With the Run Continuously and Stop buttons (on the toolbar) you don't have any control of when the program ends. That stop button halts the program wherever it happens to be in the code.

By including a while loop, you can now end your program very cleanly, and based on any number of factors. For example, you may want to end the program after an indicator reaches a certain count, or close a file after the program ends, or stop when the program reaches a certain time, etc. Look at all the example programs - there's a reason most of them have while loops.

B-)


0 Kudos
Message 3 of 4
(2,356 Views)
As others have already said, the "run continuously" button has no valid purpose in a toplevel program. It is actually named somewhat misleading, because what it really does is restarts the program automatically whenever it finishes.
 
Any bigger program consists of serveral stages, e.g. Initilizations where conditions and hardware are configured, memory allocated, files are opened, Main where the actual purpose takes place, handle operator input, display results, etc., shutdown where things get cleaned up, references closed, etc.
 
Usefull tools such as the "First run?" function loose all meaning during "run continuously". Also event structures don't work well in this mode.
 
Sure, if you are just started learning labview and just want to e.g. add two numbers (for example) you are allowed to use "run continuously" 🙂 It does not matter that the program uses 100% of the CPU doing mostly the same calculation over and over (and over and over...) again. However, in the second lesson, you should learn about loops an use them from then on. 🙂
 
One valid use for the run continuously feature is for example if you need to debug a subVI which does not contain a while loop. Using the "run continuously button" will allow you to quickly play with a series of input values while observing the result, probing the diagram, etc. It is one of the cool features of LabVIEW that subVIs can be run independenly without any need to write e.g. a primitive test caller.
0 Kudos
Message 4 of 4
(2,350 Views)