LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

For Loop runs with unwired N value

Solved!
Go to solution

In what cases will a for loop run with no N value wired to the loop? I've seen a couple of examples of the for loop running without a number of times set to be ran wired to it or for example an array size or something like that.

----------------------------------------------------------------------------------
I have not lost my mind, it's backed up on a disk somewhere
0 Kudos
Message 1 of 7
(4,304 Views)

Auto-indexing input tunnel.

Please refer to the LabVIEW help for detailed information on this.

 

Norbert

Norbert
----------------------------------------------------------------------------------------------------
CEO: What exactly is stopping us from doing this?
Expert: Geometry
Marketing Manager: Just ignore it.
0 Kudos
Message 2 of 7
(4,297 Views)

It'll run if there's an array wired in; once for each element in the array.

Jim
You're entirely bonkers. But I'll tell you a secret. All the best people are. ~ Alice
For he does not know what will happen; So who can tell him when it will occur? Eccl. 8:7

0 Kudos
Message 3 of 7
(4,293 Views)

The number of times a FOR loop runs is the minimum of what is wired to the N terminal and the size of the smallest array that is autoindexing into it.

 

So if you have two arrays autoindexing into a FOR loop, one having 3 elements and the other having 5, the loop will iterate 3 times.  If you wire a 10 to N, it will still only iterate 3 times.  If you wire a 2 to the N, then it will only run twice.  Clear as mud?


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
0 Kudos
Message 4 of 7
(4,280 Views)

Below is a program I am working on and as you can see by the image that the program runs without the N loop being wired. The program runs with no issue

----------------------------------------------------------------------------------
I have not lost my mind, it's backed up on a disk somewhere
0 Kudos
Message 5 of 7
(4,271 Views)

Why not post an image of the entire for for loop?  It seems you are stuck on the N being wired, but as others pointed out the N terminal is not the only control for how many iterations the loop runs.  Try posting a complete image if you are looking for help.

0 Kudos
Message 6 of 7
(4,241 Views)
Solution
Accepted by PauldePaor

@PauldePaor wrote:

Below is a program I am working on and as you can see by the image that the program runs without the N loop being wired. The program runs with no issue


As everyone else has been saying, you DO NOT have to wire something to N.  If you wire an array to the for-loop as an "auto-index" input, the for-loop will automatically run for the size of the smallest array.

 

Perhaps an example will help:

 

fotloop.png

 

This loops over the size of my array (in this case, 5 elements long).  The symbol on the edge of the for-loop that looks like brackets [ ], indicates that it is auto-indexed.  The loop will iterate over each element one at a time (1, then 2, then 3, then 4, then 5).

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
If someone helped you out, please select their post as the solution and/or give them Kudos!
Message 7 of 7
(4,235 Views)