From Saturday, Nov 23rd 7:00 PM CST - Sunday, Nov 24th 7:45 AM CST, ni.com will undergo system upgrades that may result in temporary service interruption.
We appreciate your patience as we improve our online experience.
From Saturday, Nov 23rd 7:00 PM CST - Sunday, Nov 24th 7:45 AM CST, ni.com will undergo system upgrades that may result in temporary service interruption.
We appreciate your patience as we improve our online experience.
This article explores some of the basic functions and uses of For Loops and While Loops in LabVIEW and the appropriate times to use them. Tutorials for both the For Loop and While Loop structures are available if you are a beginner programmer or someone looking for more instruction on configuring these loops.
A While Loop is a structure you use to execute a block of LabVIEW code repeatedly until a given condition is met. When the VI runs, the code inside the While Loop executes, and then the terminal condition is evaluated. The While Loop will be a familiar concept for experienced programmers as it operates similarly in other computer languages.
LabVIEW While Loop flowchart
Unlike a For Loop, While Loop execution does not depend on iteration count; thus, a While Loop executes indefinitely if the condition never occurs.
For more information on what a While Loop is, including its components and configuration options, look into While Loops in LabVIEW Help.
A For Loop is a structure you use to execute a block of code a set number of times. When the VI runs, the iteration count is evaluated, and then the code is executed.
LabVIEW For Loop flowchart
A For Loop can be configured to conditionally stop code execution in addition to its iteration-based exit. In these cases, the code will execute until the count terminal setting is reached or the condition is met – whichever happens first.
While Loops should be used when:
For Loops should be used when: