LabVIEW Idea Exchange

cancel
Showing results for 
Search instead for 
Did you mean: 
SteveP

Wiring array to For Loop count (N) terminal automatically sets N to array size

Status: Declined

Any idea that has received less than 6 kudos within 6 years after posting will be automatically declined.

Wiring an array (1 D) to a For Loop's Count (N) Terminal would automatically set the number of iterations to the array size.  This would avoid having to insert an Array Size primitive to accomplish that.
18 Comments
Intaris
Proven Zealot
I think it's easier to understand if you see the code what is being done with the proposed solution rather than array reshaping..... Possibly more efficient also.
RavensFan
Knight of NI

Intaris said,

 

Jlokanis,

 

the problem is that the For loop iterates EITHER

1) The number you wire to N OR

2) The smallest of any autoindexing arrays used as input.

 

Allowing to connect to the N terminal allows the user to unambiguously set the number of iterations regardless of the contents of other arrays which may also be set to autoindex.

 

 

Not completely true.  The For Loop iterates for the smallest number of either 1 or 2.  If you wire a larger number to N like 100 thinking the loop will unambiguously run 100 times, that is not true if an autoindexing array only has 5 elements.

Message Edited by Ravens Fan on 08-12-2009 12:24 PM
mfletcher
NI Employee (retired)

Even with this shortcut for setting N to the size of an array, the loop should still execute min(N, min(size of all arrays wired to auto-indexing tunnels)) iterations. It would be confusing if N had the old behavior when a scalar was wired to it and forced the actual number of iterations when an array was wired to it.

Intaris
Proven Zealot

Really?  Oh.  Indeed.  I thought the N terminal unambiguously set the number of iterations.

 

Then I see no real reason to support the array connector for the N terminal.

tst
Knight of NI Knight of NI
Knight of NI
Once upon a time Altenbach suggested that each tunnel could have "active" or "passive" indexing (or whatever other term you wish to use) - the active tunnels would determine the number of iterations and the passive ones would not. If the passive array does not have enough elements, the default value would be used. What do people think of that implementation?

___________________
Try to take over the world!
RavensFan
Knight of NI

I'd have to think of a use case for that one, but that does makes sense.

 

But another idea that may have some use.  Suppose the auto-indexed tunnel would automatically wrap around to the 0th index once it reached the end of the array?

rolfk
Knight of NI

Actually a for Loop iterates the smallest value of the N input AND the length of all autoindexing input arrays.

 

So if you wire 1000 to N but an array with only 100 values to an autoindexing tunnel it will execute 100 times.

 

I can't really see the benefit of this request either.

Rolf Kalbermatter
My Blog
Darren
Proven Zealot
Status changed to: Declined

Any idea that has received less than 6 kudos within 6 years after posting will be automatically declined.