LabVIEW Idea Exchange

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

Fixed Iteration FOR loop option

Status: Declined

National Instruments will not be implementing this idea.

Today, if we want a FOR loop with a fixed number of iterations, we need to wire a diagram constant to N. We could probably save a few clicks if we could click on N and type in an integer directly. It would also unclutter the diagram. This should of course only work if N is unwired.

 

Of course the N-Box would grow to the right to accomodate all digits

 

To later change the loop back to "normal", we would type N into the box or simply wire something numeric to N from the left.

 

As an example how it could look like, here's a simple cross product implementation (Yes, I know, LabVIEW already has a cross-product, so this is just to show the idea!)

 

Top: current implementation

Bottom: Same code after this proposed idea has been implemented

 

 

 

26 Comments
JackDunaway
Trusted Enthusiast

Brian_Powell wrote:

I'll go on the record that I'm not sold on this idea 


Same here; for another reason -- the content replaces the context. Once the N is replaced, what does 3 mean? This is a well-characterized issue/debate with the rising usage of HTML5 Placeholders in forms, and UX advocates tend to fall on the side of using explicit labels versus disappearing placeholders.

 

Spoiler
One of those one-in-a-hundred ideas where altenbach gets my 'sorry, man' rather than 'vote' 😞 Would normally not pipe up, but this idea seems to be gaining traction fast.
JackDunaway
Trusted Enthusiast

For consistency, would devs be able to type values for P and C as well?

altenbach
Knight of NI

Q3: Will you still be able to wire the "N" value inside the For Loop?  I assume so; I don't see any reason to disallow that.

 

Yes, and that is important if we also have short autoindexing arrays that reduce the iteration number. It will give the actual number of iterations determined at run time.

 

Q4: Can I wire the "N" value outside the loop and use it as a source of data?  E.g., if I want to wire my constant N value somewhere else?  Something like this...

 

No, the outside terminal is an input, not an output.

 

Once the N is replaced, what does 3 mean?

 

N=3. Why would we still call it N if it is actually a numeric constant? (Of course it could be formatted to say "N=3"). We also still have the "loop count" tip strip to remove all doubt. 😄

 

 

altenbach
Knight of NI

> Seems like syntactic sugar, which as has been noted elsewhere, isn't something we generally like to work on.

 

Not exactly the same, but the timed loop has a similar feature, where we can either wire a value or configure it internally.

Brian_Powell
Active Participant

@altenbach wrote:

Q3: Will you still be able to wire the "N" value inside the For Loop?  I assume so; I don't see any reason to disallow that.

 

Yes, and that is important if we also have short autoindexing arrays that reduce the iteration number. It will give the actual number of iterations determined at run time.

 


 

Good point.  I am troubled by this...

 

4lp.png

We have what looks like a constant wired to an indicator, but it's not.  Introducing this new paradigm is yet another exception to learn about LabVIEW and wiring.

altenbach
Knight of NI

> We have what looks like a constant wired to an indicator, but it's not.  Introducing this new paradigm is yet another exception to learn about LabVIEW and wiring.

 

Not really new. The situation is very similar if we have a constant wired to N and an indicator on the inside. (If we would create an indicator on the inside, it could automatically have a label of "actual N" or similar for guidance).actualN.png

 

I agree, the detail would need to be worked out, but this would make a nice CLAD question. 😄

 

Maybe the FOR loop properties page could be enriched with several tabs (currently, we only have appearance), one page could have a control named "upper iteration limit" with a checkbox "as wired", a checkbox to show the conditional terminal, etc. Another tab page could have the parallel FOR loop configuration (well that one could be a seperate new idea ;)), etc.

 

 

Darin.K
Trusted Enthusiast

<slightly tangential to the topic>

 

Now if 'N' meant 'N' and I mean 'N' the way it should (IMO), then this would not be an issue.  If you are going to do a 'foreach' type operation (autoindex) then N should be unwired.  If you wire 'N' then autoindexed inputs should spit default values if they run out of values, but the Loop should spin 'N' times.

 

And before you mention it, I do not really care how much you love wiring N and using autoindexing together.  I happen to like it sometimes as well.  This is purely from a syntactical simplicity standpoint.  What you see should be what you get.  And I agree with Brian here, somehow the intervening 'N' in the current construct prepares you that 'N' may be different than the constant wired in, but this new construct blurs the distinction.

 

<on topic>

If this new construct meant that a constant value inside really meant that the loop would iterate that many times no matter what autoindexing is going on, then I am almost on board.   Added bonus, with the number of iterations known at compile time it should be possible to unroll more loops.  Wired constants could remain a suggestion as they are now.

 

 

fabric
Active Participant

+1 for strictly fixed number of loops.

altenbach
Knight of NI

Darin.K: <slightly tangential to the topic>

 

On another related tangent is this idea, which did not get much attention (only 8 votes so far :()

 

Now we are getting also near my old idea of point #4 here in my post from 2006:

 

"4: We should be able to define a "dominant" autoindexing input tunnel that determines the total number of iteration even if some of the other indexing inputs tunnels have shorter (or longer) arrays wired. (It could be shown graphically slightly bigger). Other autoindexing tunnels would give default values once they run out of data (similar to the current WHILE loop behavior)."

Jeffrey_Zola
Member

Neat idea. My two cents on the discussions:

 

  1. I think that wiring an input the "N" box should become a broken wire until the number inside the box is removed somehow. That way, the value will not be removed by an unintentional termination of a wire.
  2. I agree that the value should be usable inside the loop. Perhaps there could be two ways to pull an output off of the box- one for the max array index and one for the entered value.
  3. Could the shape of the "N" box be changed to look different from the appearance of an integer constant? A different background? Shadowing? Make it a triangular shape?
  4. I would think that the "N" would have to be considered an output of the loop because the auto-indexing array, in theory, could be changed at any time when the loop is not running, thereby changing the max count. The output tunnel icon should automatically appear when the "N" is wired outside the loop to indicate this.

Jeff

Jeffrey Zola